aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2014-02-26 15:22:52 -0500
committerArthur Neves <arthurnn@gmail.com>2014-03-07 12:30:20 -0500
commita94966ea094fcfd94cf09642d3a561af80c64602 (patch)
treeb0bd592c6dcc628c92d7c33e979cbaa401806746 /activesupport/lib
parentf60b5249194d71a5a7ad152332400af39543628f (diff)
downloadrails-a94966ea094fcfd94cf09642d3a561af80c64602.tar.gz
rails-a94966ea094fcfd94cf09642d3a561af80c64602.tar.bz2
rails-a94966ea094fcfd94cf09642d3a561af80c64602.zip
Fix OrderedHash.select to return self instance.
On ruby 2.1.1 the behavior of .select and .reject has changed. They will return a Hash new instance, so we need to override them to keep the instance object class.
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/ordered_hash.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb
index 58a2ce2105..4680d5acb7 100644
--- a/activesupport/lib/active_support/ordered_hash.rb
+++ b/activesupport/lib/active_support/ordered_hash.rb
@@ -28,6 +28,10 @@ module ActiveSupport
coder.represent_seq '!omap', map { |k,v| { k => v } }
end
+ def select(*args, &block)
+ dup.tap { |hash| hash.select!(*args, &block) }
+ end
+
def reject(*args, &block)
dup.tap { |hash| hash.reject!(*args, &block) }
end