1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

OrderedHash#each* methods return self like Hash does [#6364 state:resolved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
Gabriel Horner 2011-02-02 09:58:40 -05:00 committed by Santiago Pastorino
parent 8dcacd0cc7
commit 9a0f43d3c1
2 changed files with 6 additions and 3 deletions

View file

@ -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

View file

@ -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