Module ActiveSupport::CoreExtensions::Hash::DeepMerge
In: vendor/rails/activesupport/lib/active_support/core_ext/hash/deep_merge.rb

Allows for deep merging

Methods

Public Instance methods

Returns a new hash with self and other_hash merged recursively.

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 7
 7:         def deep_merge(other_hash)
 8:           self.merge(other_hash) do |key, oldval, newval|
 9:             oldval = oldval.to_hash if oldval.respond_to?(:to_hash)
10:             newval = newval.to_hash if newval.respond_to?(:to_hash)
11:             oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval
12:           end
13:         end

Returns a new hash with self and other_hash merged recursively. Modifies the receiver in place.

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 17
17:         def deep_merge!(other_hash)
18:           replace(deep_merge(other_hash))
19:         end

[Validate]