Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions lib/bson/types/object_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ def to_a
@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.
#
Expand Down
10 changes: 7 additions & 3 deletions test/bson/object_id_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ def test_as_json
assert_equal({"$oid" => id.to_s}, id.as_json)
end

def test_to_ary
def test_object_id_array_flatten
id = ObjectId.new
assert_equal [id], id.to_ary
assert_equal Array(id), id.to_ary
assert_equal [ id ], [[ id ]].flatten
end

def test_object_id_array_flatten_bang
id = ObjectId.new
assert_equal [ id ], [[ id ]].flatten!
end
end