Class: Virtus::Equalizer
- Inherits:
-
Module
- Object
- Module
- Virtus::Equalizer
- Defined in:
- lib/virtus/support/equalizer.rb
Overview
Define equality, equivalence and inspection methods
Defined Under Namespace
Modules: Methods
Instance Method Summary collapse
-
#<<(key) ⇒ Equalizer
private
Append a key and compile the equality methods.
-
#initialize(name, keys = []) ⇒ undefined
constructor
private
Initialize an Equalizer with the given keys.
Constructor Details
#initialize(name, keys = []) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize an Equalizer with the given keys
Will use the keys with which it is initialized to define #cmp?, #hash, and #inspect
18 19 20 21 22 23 |
# File 'lib/virtus/support/equalizer.rb', line 18 def initialize(name, keys = []) @name = name.dup.freeze @keys = keys.dup define_methods include_comparison_methods end |
Instance Method Details
#<<(key) ⇒ Equalizer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Append a key and compile the equality methods
30 31 32 33 |
# File 'lib/virtus/support/equalizer.rb', line 30 def <<(key) @keys << key self end |