Sha256: 97069fd950cfb02b3d1c35c4cdc09ae8b1c22e34d0a22d9474c3f8171b5317d0

Contents?: true

Size: 416 Bytes

Versions: 4

Compression:

Stored size: 416 Bytes

Contents

class Hash
  # deep_merge_hash! by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809
  DEEP_MERGER = proc do |key, v1, v2|
    Hash === v1 && Hash === v2 ? v1.merge(v2, &DEEP_MERGER) : v2
  end

  def deep_merge(data)
    merge(data, &DEEP_MERGER)
  end unless Hash.method_defined?(:deep_merge)

  def deep_merge!(data)
    merge!(data, &DEEP_MERGER)
  end unless Hash.method_defined?(:deep_merge!)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
perkins-0.0.5 lib/core_ext/hash/deep_merge.rb
perkins-0.0.3 lib/core_ext/hash/deep_merge.rb
perkins-0.0.2 lib/core_ext/hash/deep_merge.rb
perkins-0.0.1 lib/core_ext/hash/deep_merge.rb