Sha256: a77beb3c2ed4efc6b51c6e375391ed3606b5279aec381f7f0cd9280bdbd79016

Contents?: true

Size: 391 Bytes

Versions: 16

Compression:

Stored size: 391 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

16 entries across 16 versions & 4 rubygems

Version Path
hullio-0.4.0 lib/hull/core_ext/hash.rb
hullio-0.3.3 lib/hull/core_ext/hash.rb
hullio-0.3.2 lib/hull/core_ext/hash.rb
hullio-0.3.1 lib/hull/core_ext/hash.rb
hullio-0.3.0 lib/hull/core_ext/hash.rb
hullio-0.2.1 lib/hull/core_ext/hash.rb
hullio-0.2.0 lib/hull/core_ext/hash.rb
capgun-0.2.0 lib/capgun/core_ext/hash.rb
capgun-0.1.2 lib/capgun/core_ext/hash.rb
capgun-0.1.1 lib/capgun/core_ext/hash.rb
hullio-0.1.0 lib/hull/core_ext/hash.rb
capgun-0.1.0 lib/capgun/core_ext/hash.rb
capgun-0.0.3 lib/capgun/core_ext/hash.rb
oahu-0.0.1 lib/oahu/core_ext/hash.rb
evrythng-0.1.1 lib/evrythng/core_ext/hash.rb
evrythng-0.1.0 lib/evrythng/core_ext/hash.rb