Sha256: 53da6bfaf5352a28883f7bb2cd4b563150b7e2e2f0c75b99df17b6d5f6fdf523

Contents?: true

Size: 502 Bytes

Versions: 5

Compression:

Stored size: 502 Bytes

Contents

# frozen_string_literal: true

module Chamber
module Refinements
module Hash
refine ::Hash do
  def deep_merge(other_hash, &block)
    dup.deep_merge!(other_hash, &block)
  end

  def deep_merge!(other_hash, &block)
    merge!(other_hash) do |key, this_val, other_val|
      if this_val.is_a?(::Hash) && other_val.is_a?(::Hash)
        this_val.deep_merge(other_val, &block)
      elsif block
        yield(key, this_val, other_val)
      else
        other_val
      end
    end
  end
end
end
end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chamber-3.1.1 lib/chamber/refinements/hash.rb
chamber-3.1.0 lib/chamber/refinements/hash.rb
chamber-3.0.1 lib/chamber/refinements/hash.rb
chamber-3.0.0 lib/chamber/refinements/hash.rb
chamber-3.0.0rc2 lib/chamber/refinements/hash.rb