Module: Doodle::Equality
- Defined in:
- lib/doodle/equality.rb
Overview
two doodles of the same class with the same attribute values are considered equal
Instance Method Summary collapse
Instance Method Details
#==(o) ⇒ Object
16 17 18 |
# File 'lib/doodle/equality.rb', line 16 def ==(o) eql?(o) end |
#eql?(o) ⇒ Boolean
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/doodle/equality.rb', line 5 def eql?(o) # p [:comparing, self.class, o.class, self.class == o.class] # p [:values, self.doodle.values, o.doodle.values, self.doodle.values == o.doodle.values] # p [:attributes, doodle.attributes.map { |k, a| [k, send(k).==(o.send(k))] }] res = self.class == o.class && #self.doodle.values == o.doodle.values # short circuit comparison doodle.attributes.all? { |k, a| send(k).==(o.send(k)) } # p [:res, res] res end |