Class: SuperDiff::ActiveSupport::DiffFormatters::HashWithIndifferentAccess

Inherits:
DiffFormatters::Base show all
Defined in:
lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.applies_to?(operation_tree) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb', line 5

def self.applies_to?(operation_tree)
  operation_tree.is_a?(OperationTrees::HashWithIndifferentAccess)
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb', line 9

def call
  SuperDiff::DiffFormatters::Collection.call(
    open_token: "#<HashWithIndifferentAccess {",
    close_token: "}>",
    collection_prefix: collection_prefix,
    build_item_prefix: -> (operation) {
      key =
        if operation.respond_to?(:left_key)
          operation.left_key
        else
          operation.key
        end

      if key.is_a?(Symbol)
        "#{key}: "
      else
        "#{key.inspect} => "
      end
    },
    operation_tree: operation_tree,
    indent_level: indent_level,
    add_comma: add_comma?,
  )
end