Sha256: 6ba63667c0020656eadc5d15b9e0cb3dcdc3341c3cfd7144fa3f7304b671f75e

Contents?: true

Size: 478 Bytes

Versions: 3

Compression:

Stored size: 478 Bytes

Contents

class Hash

  # Merges self with another hash, recursively.
  #
  # This code was lovingly stolen from some random gem:
  # http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html
  #
  # Thanks to whoever made it.
  def deep_merge(hash)
    target = dup

    hash.keys.each do |key|
      if hash[key].is_a? Hash and 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

3 entries across 3 versions & 1 rubygems

Version Path
hyla-1.0.3 lib/hyla/core_ext.rb
hyla-1.0.2 lib/hyla/core_ext.rb
hyla-1.0.1 lib/hyla/core_ext.rb