Merge pull request #101 from farrel/master

Added BSON::ObjectId#to_ary
This commit is contained in:
Tyler Brock 2012-06-01 11:33:52 -07:00
commit 4c032c4d31
2 changed files with 13 additions and 0 deletions

View File

@ -116,6 +116,13 @@ module BSON
@data.dup
end
# Returns the object id as a single element in an array for use with Kernel#Array
#
# @return [Array]
def to_ary
[ self ]
end
# Given a string representation of an ObjectId, return a new ObjectId
# with that value.
#

View File

@ -135,4 +135,10 @@ class ObjectIdTest < Test::Unit::TestCase
id = ObjectId.new
assert_equal({"$oid" => id.to_s}, id.as_json)
end
def test_to_ary
id = ObjectId.new
assert_equal [id], id.to_ary
assert_equal Array(id), id.to_ary
end
end