Sha256: e87e6adc0203047ee28cf8bc0411a4966bc3ded93f4d34c239129d74ce4a1e7f

Contents?: true

Size: 391 Bytes

Versions: 7

Compression:

Stored size: 391 Bytes

Contents

class Hash

  # Merges self with another hash, recursively
  #
  # @param hash [Hash] The hash to merge
  # @return [Hash]
  def deep_merge(hash)
    target = self.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])
        next
      end
      target[key] = hash[key]
    end
    target
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
angellist_api-1.1.0 lib/angellist_api/core_ext/hash.rb
angellist_api-1.0.7 lib/angellist_api/core_ext/hash.rb
angellist_api-1.0.6 lib/angellist_api/core_ext/hash.rb
angellist_api-1.0.5 lib/angellist_api/core_ext/hash.rb
angellist_api-1.0.4 lib/angellist_api/core_ext/hash.rb
angellist_api-1.0.3 lib/angellist_api/core_ext/hash.rb
angellist_api-1.0.2 lib/angellist_api/core_ext/hash.rb