Module: Doodle::Equality
- Defined in:
- lib/doodle.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
63 64 65 |
# File 'lib/doodle.rb', line 63 def ==(o) eql?(o) end |
#eql?(o) ⇒ Boolean
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/doodle.rb', line 52 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 |