Sha256: 268db731325625adb571953e3188f1a9494beb75f2d81a45827eb92b53b7c76d

Contents?: true

Size: 652 Bytes

Versions: 30

Compression:

Stored size: 652 Bytes

Contents

class Hash
  # Returns a hash that represents the difference between two hashes.
  #
  #   {1 => 2}.diff(1 => 2)         # => {}
  #   {1 => 2}.diff(1 => 3)         # => {1 => 2}
  #   {}.diff(1 => 2)               # => {1 => 2}
  #   {1 => 2, 3 => 4}.diff(1 => 2) # => {3 => 4}
  def diff(other)
    ActiveSupport::Deprecation.warn "Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead."
    dup.
      delete_if { |k, v| other[k] == v }.
      merge!(other.dup.delete_if { |k, v| has_key?(k) })
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
activesupport-4.0.13 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.13.rc1 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.11.1 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.12 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.11 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.10 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.10.rc2 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.10.rc1 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.9 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.8 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.7 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.6 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.6.rc3 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.6.rc2 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.6.rc1 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.5 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.4 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.4.rc1 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.3 lib/active_support/core_ext/hash/diff.rb
activesupport-4.0.2 lib/active_support/core_ext/hash/diff.rb