Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove deprecated Hash#diff with no replacement.

If you're using it to compare hashes for the purpose of testing,
please use MiniTest's assert_equal instead.
  • Loading branch information...
commit 01f0c3f308542afa8fa262638d94d10420bd2e78 1 parent b296edd
@carlosantoniodasilva carlosantoniodasilva authored
View
7 activesupport/CHANGELOG.md
@@ -1,3 +1,10 @@
+* Remove deprecated `Hash#diff` with no replacement.
+
+ If you're using it to compare hashes for the purpose of testing, please use
+ MiniTest's `assert_equal` instead.
+
+ *Carlos Antonio da Silva*
+
* Remove deprecated `Date#to_time_in_current_zone` in favour of `Date#in_time_zone`.
*Vipul A M*
View
1  activesupport/lib/active_support/core_ext/hash.rb
@@ -1,6 +1,5 @@
require 'active_support/core_ext/hash/conversions'
require 'active_support/core_ext/hash/deep_merge'
-require 'active_support/core_ext/hash/diff'
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/hash/keys'
View
16 activesupport/lib/active_support/core_ext/hash/diff.rb
@@ -1,16 +0,0 @@
-require 'active_support/deprecation'
-
-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
View
6 activesupport/test/core_ext/hash_ext_test.rb
@@ -701,12 +701,6 @@ def test_reverse_merge
assert_equal expected, merged
end
- def test_diff
- assert_deprecated do
- assert_equal({ :a => 2 }, { :a => 2, :b => 5 }.diff({ :a => 1, :b => 5 }))
- end
- end
-
def test_slice
original = { :a => 'x', :b => 'y', :c => 10 }
expected = { :a => 'x', :b => 'y' }
Please sign in to comment.
Something went wrong with that request. Please try again.