Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

.hash should delegate to .id for .uniq to work #128

Open
vjt opened this Issue · 0 comments

1 participant

@vjt

In order for a collection of model instances to be managed with &, |, .uniq, etc, an hash instance returning an Integer should be defined, and when invoked on two instances representing the same document it should return the same Integer.

E.g., this is incorrect behavior:

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

The straightforward solution is to add:

def hash
  id.hash
end

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

@vjt vjt referenced this issue from a commit in ifad/couchrest_model
@vjt vjt Add a Base#hash method (fixes #128) 629648d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.