Class: MismatchInspectable::HashFormatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/mismatch_inspectable/formatter/hash_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Formatter

#merge_mismatches

Constructor Details

#initializeHashFormatter

Returns a new instance of HashFormatter.



7
8
9
10
# File 'lib/mismatch_inspectable/formatter/hash_formatter.rb', line 7

def initialize
  super
  @mismatches = Hash.new { |hash, key| hash[key] = {} }
end

Instance Attribute Details

#mismatchesObject (readonly)

Returns the value of attribute mismatches.



5
6
7
# File 'lib/mismatch_inspectable/formatter/hash_formatter.rb', line 5

def mismatches
  @mismatches
end

Instance Method Details

#add_mismatch(prefix, attribute, curr_val, other_val) ⇒ Object



12
13
14
# File 'lib/mismatch_inspectable/formatter/hash_formatter.rb', line 12

def add_mismatch(prefix, attribute, curr_val, other_val)
  @mismatches[prefix + attribute.to_s] = [curr_val, other_val]
end

#process_mismatches(nested_mismatches) ⇒ Object



16
17
18
# File 'lib/mismatch_inspectable/formatter/hash_formatter.rb', line 16

def process_mismatches(nested_mismatches)
  nested_mismatches.each { |k, v| mismatches[k] = v }
end