Sha256: cf29fca939640008441cb219d2cd260af182d4310c017d25bd25c1d42f23f23b

Contents?: true

Size: 338 Bytes

Versions: 9

Compression:

Stored size: 338 Bytes

Contents

class Hash

  def deep_merge(other_hash)
    self.merge(other_hash) do |key, oldval, newval|
      oldval = oldval.to_hash if oldval.respond_to?(:to_hash)
      newval = newval.to_hash if newval.respond_to?(:to_hash)
      oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
karo-2.5.2 lib/karo/extensions/hash.rb
karo-2.5.1 lib/karo/extensions/hash.rb
karo-2.5.0 lib/karo/extensions/hash.rb
karo-2.4.0 lib/karo/extensions/hash.rb
karo-2.3.9 lib/karo/extensions/hash.rb
karo-2.3.8 lib/karo/extensions/hash.rb
karo-2.3.7 lib/karo/extensions/hash.rb
karo-2.3.6 lib/karo/extensions/hash.rb
karo-2.3.5 lib/karo/extensions/hash.rb