Class: SuperDiff::ActiveSupport::OperationTreeBuilders::HashWithIndifferentAccess
- Inherits:
-
OperationTreeBuilders::Hash
- Object
- OperationTreeBuilders::Base
- OperationTreeBuilders::Hash
- SuperDiff::ActiveSupport::OperationTreeBuilders::HashWithIndifferentAccess
- Defined in:
- lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(expected:, actual:, **rest) ⇒ HashWithIndifferentAccess
constructor
A new instance of HashWithIndifferentAccess.
Methods inherited from OperationTreeBuilders::Base
Constructor Details
#initialize(expected:, actual:, **rest) ⇒ HashWithIndifferentAccess
Returns a new instance of HashWithIndifferentAccess.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb', line 15 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 |
Class Method Details
.applies_to?(expected, actual) ⇒ Boolean
5 6 7 8 9 10 11 12 13 |
# File 'lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb', line 5 def self.applies_to?(expected, actual) ( expected.is_a?(::HashWithIndifferentAccess) && actual.is_a?(::Hash) ) || ( expected.is_a?(::Hash) && actual.is_a?(::HashWithIndifferentAccess) ) end |