From a94966ea094fcfd94cf09642d3a561af80c64602 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Wed, 26 Feb 2014 15:22:52 -0500 Subject: 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. --- activesupport/lib/active_support/ordered_hash.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activesupport/lib/active_support') 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 -- cgit v1.2.3