From 9360d0e4d794b65658f62c2289d688899f66b4a5 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Wed, 6 Jun 2012 11:24:36 +0200 Subject: [PATCH] Remove implementation of ObjectId#to_ary: - The introduction of the previous implementation breaks any attempt to flatten an array of object ids. --- lib/bson/types/object_id.rb | 7 ------- test/bson/object_id_test.rb | 10 +++++++--- 2 files changed, 7 insertions(+), 10 deletions(-) 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