Module: MongoMapper::Document::InstanceMethods
- Defined in:
- lib/mongomapper/document.rb
Instance Method Summary collapse
Instance Method Details
#collection ⇒ Object
281 282 283 |
# File 'lib/mongomapper/document.rb', line 281 def collection self.class.collection end |
#destroy ⇒ Object
297 298 299 300 301 302 303 |
# File 'lib/mongomapper/document.rb', line 297 def destroy return false if frozen? criteria = FinderOptions.to_mongo_criteria(:_id => id) collection.remove(criteria) unless new? freeze end |
#new? ⇒ Boolean
285 286 287 |
# File 'lib/mongomapper/document.rb', line 285 def new? read_attribute('_id').blank? || using_custom_id? end |
#save ⇒ Object
289 290 291 |
# File 'lib/mongomapper/document.rb', line 289 def save create_or_update end |
#save! ⇒ Object
293 294 295 |
# File 'lib/mongomapper/document.rb', line 293 def save! create_or_update || raise(DocumentNotValid.new(self)) end |