Sha256: 6c46e71f222f8ebd750f78f0a06aa32528e246694feb16dd9ebc8d9adf4f50fb

Contents?: true

Size: 495 Bytes

Versions: 2

Compression:

Stored size: 495 Bytes

Contents

# ported from active_support/core_ext/hash/deep_merge

class Hash
  # Returns a new hash with +self+ and +other_hash+ merged recursively.
  def deep_merge(other_hash)
    dup.deep_merge!(other_hash)
  end

  # Returns a new hash with +self+ and +other_hash+ merged recursively.
  # Modifies the receiver in place.
  def deep_merge!(other_hash)
    other_hash.each_pair do |k,v|
      tv = self[k]
      self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
    end
    self
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
confrider-0.1.0 lib/confrider/deep_merge.rb
confrider-0.0.2 lib/confrider/deep_merge.rb