aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-07-02 23:28:56 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-07-02 23:32:38 -0300
commit01f0c3f308542afa8fa262638d94d10420bd2e78 (patch)
tree04aea74d8c3451b63bb1ec8a0a697cdbf892e681
parentb296edd2d89623f97218fd1693b7a188b01e2171 (diff)
downloadrails-01f0c3f308542afa8fa262638d94d10420bd2e78.tar.gz
rails-01f0c3f308542afa8fa262638d94d10420bd2e78.tar.bz2
rails-01f0c3f308542afa8fa262638d94d10420bd2e78.zip
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.
-rw-r--r--activesupport/CHANGELOG.md7
-rw-r--r--activesupport/lib/active_support/core_ext/hash.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/hash/diff.rb16
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb6
4 files changed, 7 insertions, 23 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 1853c6048b..061f296dc5 100644
--- a/activesupport/CHANGELOG.md
+++ b/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*
diff --git a/activesupport/lib/active_support/core_ext/hash.rb b/activesupport/lib/active_support/core_ext/hash.rb
index 501483498d..686f12c6da 100644
--- a/activesupport/lib/active_support/core_ext/hash.rb
+++ b/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'
diff --git a/activesupport/lib/active_support/core_ext/hash/diff.rb b/activesupport/lib/active_support/core_ext/hash/diff.rb
deleted file mode 100644
index 4359213380..0000000000
--- a/activesupport/lib/active_support/core_ext/hash/diff.rb
+++ /dev/null
@@ -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
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index c6d7ab618c..0857796036 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -701,12 +701,6 @@ class HashExtTest < ActiveSupport::TestCase
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' }