class SuperDiff::OperationTreeFlatteners::Hash

Protected Instance Methods

close_token() click to toggle source
# File lib/super_diff/operation_tree_flatteners/hash.rb, line 10
def close_token
  "}"
end
item_prefix_for(operation) click to toggle source
# File lib/super_diff/operation_tree_flatteners/hash.rb, line 14
def item_prefix_for(operation)
  key = key_for(operation)

  if format_keys_as_kwargs?
    "#{key}: "
  else
    "#{key.inspect} => "
  end
end
open_token() click to toggle source
# File lib/super_diff/operation_tree_flatteners/hash.rb, line 6
def open_token
  "{"
end

Private Instance Methods

format_keys_as_kwargs?() click to toggle source
# File lib/super_diff/operation_tree_flatteners/hash.rb, line 26
def format_keys_as_kwargs?
  operation_tree.all? { |operation| key_for(operation).is_a?(Symbol) }
end
key_for(operation) click to toggle source
# File lib/super_diff/operation_tree_flatteners/hash.rb, line 30
def key_for(operation)
  # Note: We could have used the right_key here too, they're both the
  # same keys
  if operation.respond_to?(:left_key)
    operation.left_key
  else
    operation.key
  end
end