Sha256: fcd911cc9c732d5a2cb3b09295a2825f6cedc1258fee7c1fc6339e80e46291b2

Contents?: true

Size: 666 Bytes

Versions: 21

Compression:

Stored size: 666 Bytes

Contents

class Hash
  # Merge not only the hashes, but all nested hashes as well.
  # Written by Stefan Rusterholz (apeiros) from http://www.ruby-forum.com/topic/142809
  def deep_merge!(other)
    merger = lambda do |key, a, b|
      (a.is_a?(Hash) && b.is_a?(Hash)) ? a.merge!(b, &merger) : b
    end

    merge!(other, &merger)
  end

  # Merge not only the hashes, but all nested hashes as well.
  # Written by Stefan Rusterholz (apeiros) from http://www.ruby-forum.com/topic/142809
  def deep_merge(other)
    merger = lambda do |key, a, b|
      (a.is_a?(Hash) && b.is_a?(Hash)) ? a.merge(b, &merger) : b
    end

    merge(other, &merger)
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
fidgit-0.2.4 lib/fidgit/standard_ext/hash.rb
fidgit-0.2.3 lib/fidgit/standard_ext/hash.rb
fidgit-0.2.2 lib/fidgit/standard_ext/hash.rb
fidgit-0.2.1 lib/fidgit/standard_ext/hash.rb
fidgit-0.2.0 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.10 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.9 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.8 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.7 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.6 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.5 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.4 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.3 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.2 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.1 lib/fidgit/standard_ext/hash.rb
fidgit-0.1.0 lib/fidgit/standard_ext/hash.rb
fidgit-0.0.6alpha lib/fidgit/standard_ext/hash.rb
fidgit-0.0.5alpha lib/fidgit/standard_ext/hash.rb
fidgit-0.0.4alpha lib/fidgit/standard_ext/hash.rb
fidgit-0.0.3alpha lib/fidgit/standard_ext/hash.rb