Sha256: 1ba4e4d7aa7ccbf7b32bbd2135b28343b0b4392bbb3ca698fa0cb3c9932c56cc

Contents?: true

Size: 543 Bytes

Versions: 14

Compression:

Stored size: 543 Bytes

Contents

class Hash
  def reverse_merge(other_hash)
    other_hash.merge(self)
  end
  def reverse_merge!(other_hash)
    replace(reverse_merge(other_hash))
  end
  def deep_transform_keys(&block)
    result = {}
    each do |key, value|
      result[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys(&block) : value
    end
    result
  end

  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
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
jeanine-0.8.1 lib/jeanine/core_ext/hash.rb
jeanine-0.8 lib/jeanine/core_ext/hash.rb
jeanine-0.7.8 lib/jeanine/core_ext/hash.rb
jeanine-0.7.7 lib/jeanine/core_ext/hash.rb
jeanine-0.7.6 lib/jeanine/core_ext/hash.rb
jeanine-0.7.5 lib/jeanine/core_ext/hash.rb
jeanine-0.7.4 lib/jeanine/core_ext/hash.rb
jeanine-0.7.3.2 lib/jeanine/core_ext/hash.rb
jeanine-0.7.3.1 lib/jeanine/core_ext/hash.rb
jeanine-0.7.3 lib/jeanine/core_ext/hash.rb
jeanine-0.7.2 lib/jeanine/core_ext/hash.rb
jeanine-0.7.1 lib/jeanine/core_ext/hash.rb
jeanine-0.7.0 lib/jeanine/core_ext/hash.rb
jeanine-0.6.0 lib/jeanine/core_ext/hash.rb