Method: MongoDoc::Document#to_bson
- Defined in:
- lib/mongo_doc/document.rb
#to_bson(*args) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/mongo_doc/document.rb', line 92 def to_bson(*args) {MongoDoc::BSON::CLASS_KEY => self.class.name}.tap do |bson_hash| bson_hash['_id'] = _id unless new_record? self.class._attributes.each do |name| bson_hash[name.to_s] = send(name).to_bson(args) end if MongoDoc::Configuration.dynamic_attributes && dynamic_attributes.any? bson_hash.merge!(dynamic_attributes) end end end |