Sha256: 689c7ff489d9d63ba291b78433e9022ff5aa5b40c5bfaf60a989fcc81d4bf610

Contents?: true

Size: 440 Bytes

Versions: 206

Compression:

Stored size: 440 Bytes

Contents

class Hash
  # Returns a new hash with +self+ and +other_hash+ merged recursively.
  def deep_merge(other_hash)
    dup.deep_merge!(other_hash)
  end

  # 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 |k,v|
      tv = self[k]
      self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
    end
    self
  end
end

Version data entries

206 entries across 193 versions & 10 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/hash/deep_merge.rb
classiccms-0.7.4 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/hash/deep_merge.rb
classiccms-0.7.3 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/hash/deep_merge.rb
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/activesupport-3.0.0/lib/active_support/core_ext/hash/deep_merge.rb
classiccms-0.7.2 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/hash/deep_merge.rb
classiccms-0.7.1 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/hash/deep_merge.rb
classiccms-0.7.0 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/hash/deep_merge.rb
activesupport-3.1.12 lib/active_support/core_ext/hash/deep_merge.rb
activesupport-3.1.11 lib/active_support/core_ext/hash/deep_merge.rb
activesupport-3.0.20 lib/active_support/core_ext/hash/deep_merge.rb
activesupport-3.1.10 lib/active_support/core_ext/hash/deep_merge.rb
activesupport-3.0.19 lib/active_support/core_ext/hash/deep_merge.rb
activesupport-3.1.9 lib/active_support/core_ext/hash/deep_merge.rb
activesupport-3.0.18 lib/active_support/core_ext/hash/deep_merge.rb
classiccms-0.6.9 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/hash/deep_merge.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/core_ext/hash/deep_merge.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/core_ext/hash/deep_merge.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/core_ext/hash/deep_merge.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/core_ext/hash/deep_merge.rb
classiccms-0.6.8 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/hash/deep_merge.rb