Class: MismatchInspectable::HashFormatter
- Defined in:
- lib/mismatch_inspectable/formatter/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.
- #process_mismatches(nested_mismatches) ⇒ Object
Methods inherited from Formatter
Constructor Details
#initialize ⇒ HashFormatter
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
#mismatches ⇒ Object (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 |