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')