diff --git a/lib/bson/types/object_id.rb b/lib/bson/types/object_id.rb index afbc128397..6bfb7dce58 100644 --- a/lib/bson/types/object_id.rb +++ b/lib/bson/types/object_id.rb @@ -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. # diff --git a/test/bson/object_id_test.rb b/test/bson/object_id_test.rb index 78f93ea184..2d8a2b6d52 100644 --- a/test/bson/object_id_test.rb +++ b/test/bson/object_id_test.rb @@ -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