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

ActiveSupport::OrderedHash#to_a method returns an ordered set of arrays. Matches ruby1.9's Hash#to_a.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#2629 state:committed]
This commit is contained in:
Ken Collins 2009-05-09 18:35:31 -04:00 committed by Michael Koziarski
parent 235775de29
commit 9e0cfdb7f9
2 changed files with 8 additions and 0 deletions

View file

@ -57,6 +57,10 @@ module ActiveSupport
self
end
def to_a
@keys.map { |key| [ key, self[key] ] }
end
def each_key
@keys.each { |key| yield key }
end

View file

@ -51,6 +51,10 @@ class OrderedHashTest < Test::Unit::TestCase
assert_same @ordered_hash, @ordered_hash.to_hash
end
def test_to_a
assert_equal @keys.zip(@values), @ordered_hash.to_a
end
def test_has_key
assert_equal true, @ordered_hash.has_key?('blue')
assert_equal true, @ordered_hash.key?('blue')