Serializing a hash with an Object Id throws an undefined method error.
1.9.3-p374 :001 > {:custom_fields=>{BSON::ObjectId.from_string('53593be85261753a38000000')=>"ABC", BSON::ObjectId.from_string('53593be85261753a38010000')=>["123", "234"]}}.to_bson
NoMethodError: undefined method `to_bson_key' for BSON::ObjectId('53593be85261753a38000000'):BSON::ObjectId
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:45:in `block (2 levels) in to_bson'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:43:in `each'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:43:in `block in to_bson'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/encodable.rb:57:in `encode_with_placeholder_and_null'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:42:in `to_bson'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:46:in `block (2 levels) in to_bson'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:43:in `each'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:43:in `block in to_bson'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/encodable.rb:57:in `encode_with_placeholder_and_null'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:42:in `to_bson'
from (irb):1
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/railties-4.1.0/lib/rails/commands/console.rb:90:in `start'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/railties-4.1.0/lib/rails/commands/console.rb:9:in `start'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:69:in `console'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'