Sha256: 3d10765347dbf96412b15e3d1840e77c0185a077289be267e8055fa25e8f9f77

Contents?: true

Size: 401 Bytes

Versions: 1

Compression:

Stored size: 401 Bytes

Contents

module Wingtips
  module HashUtils
    extend self

    def deep_merge(hash1, hash2)
      deep_merge!(hash1.dup, hash2)
    end

    def deep_merge!(hash1, hash2)
      hash1.merge! hash2 do |_key, value1, value2|
        if value1.respond_to?(:merge!) && value2.respond_to?(:merge!)
          HashUtils.deep_merge! value1, value2
        else
          value2
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wingtips-0.2.0 lib/wingtips/hash_utils.rb