Module: Equalizer::InstanceMethods Private
- Defined in:
- lib/equalizer.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance methods mixed into classes that include an Equalizer module
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
private
Equality comparison allowing subclasses.
-
#deconstruct ⇒ Array
private
Array deconstruction for pattern matching.
-
#deconstruct_keys(requested) ⇒ Hash{Symbol => Object}
private
Hash deconstruction for pattern matching.
-
#eql?(other) ⇒ Boolean
private
Strict equality requiring exact class match.
-
#hash ⇒ Integer
private
Hash code based on class and attribute values.
Instance Method Details
#==(other) ⇒ Boolean
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.
Equality comparison allowing subclasses
79 80 81 82 |
# File 'lib/equalizer.rb', line 79 def ==(other) other.is_a?(self.class) && cmp?(:==, other) end |
#deconstruct ⇒ Array
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.
Array deconstruction for pattern matching
103 104 105 |
# File 'lib/equalizer.rb', line 103 def deconstruct equalizer_keys.map { |key| public_send(key) } end |
#deconstruct_keys(requested) ⇒ Hash{Symbol => Object}
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.
Hash deconstruction for pattern matching
111 112 113 114 |
# File 'lib/equalizer.rb', line 111 def deconstruct_keys(requested) subset = requested.nil? ? equalizer_keys : equalizer_keys & requested subset.to_h { |key| [key, public_send(key)] } end |
#eql?(other) ⇒ Boolean
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.
Strict equality requiring exact class match
88 89 90 91 |
# File 'lib/equalizer.rb', line 88 def eql?(other) other.instance_of?(self.class) && cmp?(:eql?, other) end |
#hash ⇒ Integer
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.
Hash code based on class and attribute values
96 97 98 |
# File 'lib/equalizer.rb', line 96 def hash [self.class, *deconstruct].hash end |