Class: SuperDiff::ActiveSupport::OperationTreeBuilders::HashWithIndifferentAccess

Inherits:
OperationTreeBuilders::Hash show all
Defined in:
lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb

Instance Method Summary collapse

Methods inherited from OperationTreeBuilders::Hash

applies_to?

Methods inherited from OperationTreeBuilders::Base

applies_to?, #call

Constructor Details

#initialize(expected:, actual:, **rest) ⇒ HashWithIndifferentAccess

Returns a new instance of HashWithIndifferentAccess.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb', line 5

def initialize(expected:, actual:, **rest)
  super

  if expected.is_a?(::HashWithIndifferentAccess)
    @expected = expected.to_h
    @actual = actual.transform_keys(&:to_s)
  end

  if actual.is_a?(::HashWithIndifferentAccess)
    @expected = expected.transform_keys(&:to_s)
    @actual = actual.to_h
  end
end