couchrest/couchrest_model — Issue #128: .hash should delegate to .id for .uniq to work
Author: vjt
Created: 2011-11-16 21:29:49+00:00
State: open

In order for a collection of model instances to be managed with `&`, `|`, `.uniq`, etc, an `hash` instance method should be defined. It should return an `Integer` two instances representing the same document should return the same `Integer`.

E.g., this is incorrect behavior:

```ruby
(rdb:1) User.first.id == User.first.id
true
(rdb:1) User.first.hash == User.first.hash
false
```

The straightforward solution is to add:

```ruby
def hash
id.hash
end
```

to `CouchRest::Model::Base`. What do you think?