Added BSON::ObjectId#to_ary
This commit is contained in:
parent
5591e3dfe3
commit
078354a39a
@ -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
Block a user