Class: MismatchInspectable::HashFormatter
- Inherits:
-
Object
- Object
- MismatchInspectable::HashFormatter
- Defined in:
- lib/mismatch_inspectable/hash_formatter.rb
Instance Attribute Summary collapse
-
#mismatches ⇒ Object
readonly
Returns the value of attribute mismatches.
Instance Method Summary collapse
- #add_mismatch(prefix, attribute, curr_val, other_val) ⇒ Object
-
#initialize ⇒ HashFormatter
constructor
A new instance of HashFormatter.
- #merge_mismatches(nested_mismatches) ⇒ Object
Constructor Details
#initialize ⇒ HashFormatter
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
#mismatches ⇒ Object (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 |