diff options
author | Gabriel Horner <gabriel.horner@gmail.com> | 2011-02-02 09:58:40 -0500 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-02-02 13:40:36 -0200 |
commit | 9a0f43d3c1dd35fde074af6cc2825ae1872aabef (patch) | |
tree | 4e8787a67f10d04125c88b2b685e03caf1a55ebf | |
parent | 8dcacd0cc7fe634ed0bedbc21dfbb0da46298686 (diff) | |
download | rails-9a0f43d3c1dd35fde074af6cc2825ae1872aabef.tar.gz rails-9a0f43d3c1dd35fde074af6cc2825ae1872aabef.tar.bz2 rails-9a0f43d3c1dd35fde074af6cc2825ae1872aabef.zip |
OrderedHash#each* methods return self like Hash does [#6364 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
-rw-r--r-- | activesupport/lib/active_support/ordered_hash.rb | 3 | ||||
-rw-r--r-- | activesupport/test/ordered_hash_test.rb | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb index ac20988230..b2f04b427b 100644 --- a/activesupport/lib/active_support/ordered_hash.rb +++ b/activesupport/lib/active_support/ordered_hash.rb @@ -138,14 +138,17 @@ module ActiveSupport def each_key @keys.each { |key| yield key } + self end def each_value @keys.each { |key| yield self[key]} + self end def each @keys.each {|key| yield [key, self[key]]} + self end alias_method :each_pair, :each diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb index 09203465c3..d2cfd3698f 100644 --- a/activesupport/test/ordered_hash_test.rb +++ b/activesupport/test/ordered_hash_test.rb @@ -78,19 +78,19 @@ class OrderedHashTest < Test::Unit::TestCase def test_each_key keys = [] - @ordered_hash.each_key { |k| keys << k } + assert_equal @ordered_hash, @ordered_hash.each_key { |k| keys << k } assert_equal @keys, keys end def test_each_value values = [] - @ordered_hash.each_value { |v| values << v } + assert_equal @ordered_hash, @ordered_hash.each_value { |v| values << v } assert_equal @values, values end def test_each values = [] - @ordered_hash.each {|key, value| values << value} + assert_equal @ordered_hash, @ordered_hash.each {|key, value| values << value} assert_equal @values, values end |