Comparing using attribute hash if ids are nil
This commit is contained in:
parent
a8a1372e57
commit
e91812ca53
3 changed files with 38 additions and 13 deletions
|
@ -99,7 +99,12 @@ module CouchRest
|
|||
# a Hash comparison on the attributes.
|
||||
def == other
|
||||
return false unless other.is_a?(Base)
|
||||
database == other.database && id == other.id
|
||||
if id.nil? && other.id.nil?
|
||||
# no ids? assume comparing nested and revert to hash comparison
|
||||
to_hash == other.to_hash
|
||||
else
|
||||
database == other.database && id == other.id
|
||||
end
|
||||
end
|
||||
alias :eql? :==
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue