Class: MismatchInspectable::HashFormatter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHashFormatter

Returns a new instance of HashFormatter.



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

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

Instance Attribute Details

#mismatchesObject (readonly)

Returns the value of attribute mismatches.



3
4
5
# File 'lib/mismatch_inspectable/hash_formatter.rb', line 3

def mismatches
  @mismatches
end

Instance Method Details

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



9
10
11
# File 'lib/mismatch_inspectable/hash_formatter.rb', line 9

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

#merge_mismatches(nested_mismatches) ⇒ Object



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

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