Module: MongoHashie::InstanceMethods
- Defined in:
- lib/mongo-hashie/base.rb
Instance Method Summary collapse
Instance Method Details
#collection ⇒ Object
14 15 16 |
# File 'lib/mongo-hashie/base.rb', line 14 def collection self.class.db.collection(self.class.name) end |
#destroy ⇒ Object
29 30 31 |
# File 'lib/mongo-hashie/base.rb', line 29 def destroy collection.remove('_id' => self._id) end |
#save ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mongo-hashie/base.rb', line 18 def save if self._id.nil? self._id = BSON::ObjectId.new collection.insert(self) else collection.update({'_id' => self._id}, self) end update_keys if MongoHashie::Configuration. and not self.is_a?(MetaDataProperties) self end |