Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2874 from sikachu/3-1-stable-extractable_ordered_…

…hash

Make `ActiveSupport::OrderedHash` extractable when using `Array#extract_options!`
  • Loading branch information...
commit a7f55324b9548a7b71fb2099785566a109edf79d 2 parents 76d3b47 + d1a2701
@spastorino spastorino authored
View
4 activesupport/CHANGELOG
@@ -1,3 +1,7 @@
+*Rails 3.1.1 (unreleased)*
+
+* ActiveSupport::OrderedHash is now marked as extractable when using Array#extract_options! [Prem Sichanugrist]
+
*Rails 3.1.0 (August 30, 2011)*
* ActiveSupport::Dependencies#load and ActiveSupport::Dependencies#require now
View
5 activesupport/lib/active_support/ordered_hash.rb
@@ -47,6 +47,11 @@ def nested_under_indifferent_access
self
end
+ # Returns true to make sure that this hash is extractable via <tt>Array#extract_options!</tt>
+ def extractable_options?
+ true
+ end
+
# Hash is ordered in Ruby 1.9!
if RUBY_VERSION < '1.9'
View
5 activesupport/test/ordered_hash_test.rb
@@ -306,4 +306,9 @@ def test_invert
assert_equal expected, @ordered_hash.invert
assert_equal @values.zip(@keys), @ordered_hash.invert.to_a
end
+
+ def test_extractable
+ @ordered_hash[:rails] = "snowman"
+ assert_equal @ordered_hash, [1, 2, @ordered_hash].extract_options!
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.