Permalink
Browse files

OrderedHash#each* methods return self like Hash does [#6364 state:res…

…olved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
1 parent 8dcacd0 commit 9a0f43d3c1dd35fde074af6cc2825ae1872aabef @cldwalker cldwalker committed with spastorino Feb 2, 2011
Showing with 6 additions and 3 deletions.
  1. +3 −0 activesupport/lib/active_support/ordered_hash.rb
  2. +3 −3 activesupport/test/ordered_hash_test.rb
@@ -138,14 +138,17 @@ def to_a
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
@@ -78,19 +78,19 @@ def test_has_value
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

0 comments on commit 9a0f43d

Please sign in to comment.