Module: MongoMapper::Document::InstanceMethods
- Defined in:
- lib/mongo_mapper/document.rb
Instance Method Summary collapse
- #collection ⇒ Object
- #destroy ⇒ Object
- #new? ⇒ Boolean
- #reload ⇒ Object
- #save ⇒ Object
- #save! ⇒ Object
Instance Method Details
#collection ⇒ Object
427 428 429 |
# File 'lib/mongo_mapper/document.rb', line 427 def collection self.class.collection end |
#destroy ⇒ Object
443 444 445 446 447 |
# File 'lib/mongo_mapper/document.rb', line 443 def destroy return false if frozen? self.class.delete(id) unless new? freeze end |
#new? ⇒ Boolean
431 432 433 |
# File 'lib/mongo_mapper/document.rb', line 431 def new? read_attribute('_id').blank? || using_custom_id? end |
#reload ⇒ Object
449 450 451 |
# File 'lib/mongo_mapper/document.rb', line 449 def reload self.class.find(id) end |
#save ⇒ Object
435 436 437 |
# File 'lib/mongo_mapper/document.rb', line 435 def save valid? ? create_or_update : false end |
#save! ⇒ Object
439 440 441 |
# File 'lib/mongo_mapper/document.rb', line 439 def save! valid? ? create_or_update : raise(DocumentNotValid.new(self)) end |