commit
4c032c4d31
|
@ -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.
|
||||
#
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue