mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04: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:
committed by
Michael Koziarski
parent
235775de29
commit
9e0cfdb7f9
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user