Sha256: 50e67c2fd3c0ebf9d4a5c4316503e8b3d23efa13b7696098f7e03ecb6a8fd992
Contents?: true
Size: 695 Bytes
Versions: 13
Compression:
Stored size: 695 Bytes
Contents
module Gorillib module Hashlike module DeepMerge # Returns a new hash with +self+ and +other_hash+ merged recursively. def deep_merge(other_hash) dup.deep_merge!(other_hash) end unless method_defined?(:deep_merge) # Returns a new hash with +self+ and +other_hash+ merged recursively. # Modifies the receiver in place. def deep_merge!(other_hash) other_hash.each_pair do |ok, ov| ov = convert_value(ov) if respond_to?(:convert_value) sv = self[ok] self[ok] = sv.is_a?(Hash) && ov.is_a?(Hash) ? sv.deep_merge(ov) : ov end self end unless method_defined?(:deep_merge!) end end end
Version data entries
13 entries across 13 versions & 1 rubygems