module ActiveSupportHashHelpers

active_support helpers

Public Instance Methods

deep_merge(other_hash, &block) click to toggle source
# File lib/dip/ext/hash.rb, line 19
def deep_merge(other_hash, &block)
  dup.deep_merge!(other_hash, &block)
end
deep_merge!(other_hash, &block) click to toggle source
# File lib/dip/ext/hash.rb, line 23
def deep_merge!(other_hash, &block)
  merge!(other_hash) do |key, this_val, other_val|
    if this_val.is_a?(Hash) && other_val.is_a?(Hash)
      this_val.deep_merge(other_val, &block)
    elsif block
      block.call(key, this_val, other_val)
    else
      other_val
    end
  end
end
deep_symbolize_keys!() click to toggle source
# File lib/dip/ext/hash.rb, line 6
def deep_symbolize_keys!
  deep_transform_keys! { |key| key.respond_to?(:to_sym) ? key.to_sym : key }
end
deep_transform_keys!() { |key| ... } click to toggle source
# File lib/dip/ext/hash.rb, line 10
def deep_transform_keys!(&block)
  keys.each do |key|
    value = delete(key)
    self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value
  end

  self
end