Sha256: fb699f1ec6cefe0abd033022ad0dfd1ceaca57848eef1d80630de8bc3464d3e5

Contents?: true

Size: 424 Bytes

Versions: 5

Compression:

Stored size: 424 Bytes

Contents

# frozen_string_literal: true

class Hash
  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

  def deep_merge(other_hash, &)
    dup.deep_merge!(other_hash, &)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
platformos-check-0.4.14 lib/platformos_check/ext/hash.rb
platformos-check-0.4.13 lib/platformos_check/ext/hash.rb
platformos-check-0.4.12 lib/platformos_check/ext/hash.rb
platformos-check-0.4.11 lib/platformos_check/ext/hash.rb
platformos-check-0.4.10 lib/platformos_check/ext/hash.rb