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).
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 |