method
deep_merge!
v4.1.8 -
Show latest stable
- Class:
Hash
deep_merge!(other_hash, &block)public
Same as deep_merge, but modifies self.
# 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 Related methods
- Instance methods
- as_json
- assert_valid_keys
- compact
- compact!
- deep_dup
- deep_merge
- deep_merge!
- deep_stringify_keys
- deep_stringify_keys!
- deep_symbolize_keys
- deep_symbolize_keys!
- deep_transform_keys
- deep_transform_keys!
- except
- except!
- extract!
- extractable_options?
- nested_under_indifferent_access
- reverse_merge
- reverse_merge!
- reverse_update
- slice
- slice!
- stringify_keys
- stringify_keys!
- symbolize_keys
- symbolize_keys!
- to_options
- to_options!
- to_param
- to_query
- to_xml
- transform_keys
- transform_keys!
- with_indifferent_access
- Class methods
- from_trusted_xml
- from_xml
- Private methods
-
_deep_transform_keys_in_object -
_deep_transform_keys_in_object!