Sha256: a9a133c7f9445d2cddf25aceaeb202a55a3157569967d0589fd2b6a8fee88d90

Contents?: true

Size: 524 Bytes

Versions: 15

Compression:

Stored size: 524 Bytes

Contents

module Dply
  module HashExt
    refine Hash do

      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_given?
            block.call(key, this_val, other_val)
          else
            other_val
          end
        end
      end

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

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dply-0.3.15 lib/dply/ext/hash.rb
dply-0.3.14 lib/dply/ext/hash.rb
dply-0.3.13 lib/dply/ext/hash.rb
dply-0.3.12 lib/dply/ext/hash.rb
dply-0.3.11 lib/dply/ext/hash.rb
dply-0.3.10 lib/dply/ext/hash.rb
dply-0.3.9 lib/dply/ext/hash.rb
dply-0.3.8 lib/dply/ext/hash.rb
dply-0.3.7 lib/dply/ext/hash.rb
dply-0.3.6 lib/dply/ext/hash.rb
dply-0.3.5 lib/dply/ext/hash.rb
dply-0.3.4 lib/dply/ext/hash.rb
dply-0.3.3 lib/dply/ext/hash.rb
dply-0.3.2 lib/dply/ext/hash.rb
dply-0.3.1 lib/dply/ext/hash.rb