Module: LunaPark::Extensions::ComparableDebug
- Defined in:
- lib/luna_park/extensions/comparable_debug.rb
Overview
Debug for #== method
Instance Method Summary collapse
-
#detailed_comparsion(other) ⇒ Object
(also: #detailed_cmp)
Returns nested Hash represents full comparsion that contains: In root: { ‘bool` => { … } } (that describes result of compasrion with detailed cmp in hash value) AND { :field_name => { `bool` => … } } (that describes concrete field comparsion) OR { `bool` => [left, right] } } (that describes result of left and right objects compasrion).
-
#detailed_differences(other) ⇒ Object
(also: #detailed_diff)
Returns only different values, that causes missmatch.
Instance Method Details
#detailed_comparsion(other) ⇒ Object Also known as: detailed_cmp
Returns nested Hash represents full comparsion that contains:
In root:
{ `bool` => { ... } } (that describes result of compasrion with detailed cmp in hash value)
AND
{ :field_name => { `bool` => ... } } (that describes concrete field comparsion)
OR
{ `bool` => [left, right] } } (that describes result of left and right objects compasrion)
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/luna_park/extensions/comparable_debug.rb', line 50 def detailed_comparsion(other) diff = self.class.comparable_attributes_list.each_with_object({}) do |field, output| left = send(field) right = other&.send(field) output[field] = if left.respond_to?(:detailed_comparsion) left.detailed_comparsion(right) else { (left == right) => [left, right] } end end { (self == other) => diff } end |
#detailed_differences(other) ⇒ Object Also known as: detailed_diff
Returns only different values, that causes missmatch
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/luna_park/extensions/comparable_debug.rb', line 78 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 |