Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ActiveSupport::OrderedHash extractable when using `Array#extract_options! #2827

Merged
merged 1 commit into from Sep 3, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*Rails 3.2.0 (unreleased)*

* ActiveSupport::OrderedHash is now marked as extractable when using Array#extract_options! [Prem Sichanugrist]

* Added Array#prepend as an alias for Array#unshift and Array#append as an alias for Array#<< [DHH]

* The definition of blank string for Ruby 1.9 has been extended to Unicode whitespace.
Expand Down
5 changes: 5 additions & 0 deletions activesupport/lib/active_support/ordered_hash.rb
Expand Up @@ -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'

Expand Down
5 changes: 5 additions & 0 deletions activesupport/test/ordered_hash_test.rb
Expand Up @@ -329,4 +329,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