mongodb/mongo-ruby-driver — pull request #107 by durran (2012-06-06 09:36:03+00:00)
Title: Revert ObjectId#to_ary

The introduction of commit 078354a39a985d84e8597425535f7b6b3c3fdfcf breaks any application that would attempt to flatten an array of object ids, forcing it to appear hung and never exiting (and really hard to debug for those who don't have a deep knowledge of Ruby's core API). Since we do this in Mongoid, and I'm sure many others do, release 1.6.2 is unusable.

The proper implementation of this would be to return `nil` from `to_ary` in order to allow proper flattening. However `BSON::ObjectId` does not follow Ruby conventions with respect to `to_a` either, which returns the internal data instead of the object id wrapped in an array.

I was about to re-implement `to_a` as well, however this has repercussions as there are current expectations around what `to_a` returns in the driver albeit incorrect. So this pull is simply to get the driver back to a reusable state with tests around `Array#flatten` and `Array#flatten!` to ensure this isn't broken again.

There needs to be an overhaul of this class with regards to core Ruby APIs and what they are expected to return, as simple changes like this have rippling affects. `to_a` needs to change to adhere to this, but it's going to break other things as well. IMO it's best to stay with the existing functionality to not be breaking apps in patch releases.