Class: SuperDiff::ActiveSupport::OperationTreeBuilders::HashWithIndifferentAccess
- Inherits:
-
Basic::OperationTreeBuilders::Hash
- Object
- Core::AbstractOperationTreeBuilder
- Basic::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 Core::AbstractOperationTreeBuilder
Constructor Details
#initialize(expected:, actual:, **rest) ⇒ HashWithIndifferentAccess
Returns a new instance of HashWithIndifferentAccess.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb', line 17 def initialize(expected:, actual:, **rest) super if expected.is_a?(::HashWithIndifferentAccess) @expected = expected.to_h @actual = actual.transform_keys(&:to_s) end return unless actual.is_a?(::HashWithIndifferentAccess) @expected = expected.transform_keys(&:to_s) @actual = actual.to_h end |
Class Method Details
.applies_to?(expected, actual) ⇒ Boolean
7 8 9 10 11 12 13 14 15 |
# File 'lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb', line 7 def self.applies_to?(expected, actual) ( expected.is_a?(::HashWithIndifferentAccess) && actual.is_a?(::Hash) ) || ( expected.is_a?(::Hash) && actual.is_a?(::HashWithIndifferentAccess) ) end |