Sha256: bd695445af71f8a00baa614d07c440c8536d82aa358c727a5303ce2f333bb4e3

Contents?: true

Size: 392 Bytes

Versions: 11

Compression:

Stored size: 392 Bytes

Contents

class Hash

  # Merges self with another hash, recursively
  #
  # @param hash [Hash] The hash to merge
  # @return [Hash]
  def deep_merge(hash)
    target = self.dup
    hash.keys.each do |key|
      if hash[key].is_a?(Hash) && self[key].is_a?(Hash)
        target[key] = target[key].deep_merge(hash[key])
        next
      end
      target[key] = hash[key]
    end
    target
  end


end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
flattr-0.3.7 lib/flattr/core_ext/hash.rb
flattr-0.3.6 lib/flattr/core_ext/hash.rb
flattr-0.3.5 lib/flattr/core_ext/hash.rb
flattr-0.3.4 lib/flattr/core_ext/hash.rb
flattr-0.3.3 lib/flattr/core_ext/hash.rb
flattr-0.3.2 lib/flattr/core_ext/hash.rb
flattr-0.3.1 lib/flattr/core_ext/hash.rb
flattr-0.3.0 lib/flattr/core_ext/hash.rb
flattr-0.2.3 lib/flattr/core_ext/hash.rb
flattr-0.2.2 lib/flattr/core_ext/hash.rb
flattr-0.2.1 lib/flattr/core_ext/hash.rb