instance method
deep_merge!
Ruby on Rails 4.0.13
Since v2.3.18Signature
deep_merge!(other_hash, &block)
Same as deep_merge, but modifies self.
Parameters
-
other_hashreq -
blockblock
Source
# File activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 21
def deep_merge!(other_hash, &block)
other_hash.each_pair do |current_key, other_value|
this_value = self[current_key]
self[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)
this_value.deep_merge(other_value, &block)
else
if block_given? && key?(current_key)
block.call(current_key, this_value, other_value)
else
other_value
end
end
end
self
end
Defined in activesupport/lib/active_support/core_ext/hash/deep_merge.rb line 21
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Hash