Module: Charisma::Curator::LooseEquality
- Defined in:
- lib/charisma/curator.rb
Overview
Loose equality for Hashlike objects
Hash#==
as defined in Ruby core is very, very strict: it uses Object#==
on each of its values to determine equality. This module overrides #==
to loosen this evaluation.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Determine equality with another Hashlike object, loosely.
Instance Method Details
#==(other) ⇒ Object
Determine equality with another Hashlike object, loosely.
Unlike Ruby’s own Hash#==
, this method uses the values’ native #==
methods, where available, to determine equality.
86 87 88 89 90 91 |
# File 'lib/charisma/curator.rb', line 86 def ==(other) return false unless keys.sort == other.keys.sort keys.all? do |k| self[k] == other[k] end end |