Sha256: f16083390ee13d5b78c1abca33d662191b78fd563e477905dcf7167fd4651a75

Contents?: true

Size: 269 Bytes

Versions: 3

Compression:

Stored size: 269 Bytes

Contents

class Hash
  def deep_merge(hash)
    target = dup

    hash.keys.each do |key|
      if hash[key].is_a?(Hash) && self[key].is_a?(Hash)
        target[key] = target[key].deep_merge(hash[key])
      end
      
      target[key] = hash[key]
    end

    target
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ebooks-0.2.1 lib/ebooks/core_ext.rb
ebooks-0.2.0 lib/ebooks/core_ext.rb
ebooks-0.1.0 lib/ebooks/core_ext.rb