Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/mixers/equitable.rb
Instance Method Summary collapse
-
#Equitable(*accessors) ⇒ Object
This function provided a “shortcut” for creating the #identity method based on given accessors and returns the Equitable module for inclusion.
Instance Method Details
#Equitable(*accessors) ⇒ Object
This function provided a “shortcut” for creating the #identity method based on given accessors and returns the Equitable module for inclusion.
include Equitable(:a, :b)
is equivalent to including a module containing:
def ==(other)
self.a == other.a && self.b == other.b
end
def eql?(other)
self.a.eql?(other.a) && self.b.eql?(other.b)
end
def hash()
self.a.hash ^ self.b.hash
end
71 72 73 |
# File 'lib/mixers/equitable.rb', line 71 def Equitable(*accessors) Equitable.identify(self, *accessors) end |