Module: LunaPark::Extensions::Comparable::InstanceMethods
- Defined in:
- lib/luna_park/extensions/comparable.rb
Instance Method Summary collapse
-
#detailed_differences(other) ⇒ Object
(also: #detailed_diff)
Returns only different values, that causes missmatch.
-
#enable_debug ⇒ Object
(also: #debug)
Enable debug mode (just include debug methods).
-
#eql?(other) ⇒ Boolean
(also: #==)
Compare this object with other using methids, described with ‘::comparable_attributes` method.
Instance Method Details
#detailed_differences(other) ⇒ Object Also known as: detailed_diff
Returns only different values, that causes missmatch
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/luna_park/extensions/comparable.rb', line 90 def detailed_differences(other) self.class.comparable_attributes_list.each_with_object({}) do |field, output| left = send(field) right = other&.send(field) next if left == right output[field] = if left.respond_to?(:detailed_differences) left.detailed_differences(right) else [left, right] end end end |
#enable_debug ⇒ Object Also known as: debug
Enable debug mode (just include debug methods)
109 110 111 112 |
# File 'lib/luna_park/extensions/comparable.rb', line 109 def enable_debug self.class.enable_debug self end |
#eql?(other) ⇒ Boolean Also known as: ==
Compare this object with other using methids, described with ‘::comparable_attributes` method
71 72 73 74 75 |
# File 'lib/luna_park/extensions/comparable.rb', line 71 def eql?(other) return false unless other.is_a?(self.class) self.class.comparable_attributes_list.all? { |attr| send(attr) == other.send(attr) } end |