Module: MongoMapper::Document::InstanceMethods
- Defined in:
- lib/mongo_mapper/document.rb
Instance Method Summary collapse
Instance Method Details
#collection ⇒ Object
248 249 250 |
# File 'lib/mongo_mapper/document.rb', line 248 def collection self.class.collection end |
#destroy ⇒ Object
264 265 266 267 268 269 270 |
# File 'lib/mongo_mapper/document.rb', line 264 def destroy return false if frozen? criteria = FinderOptions.to_mongo_criteria(:_id => id) collection.remove(criteria) unless new? freeze end |
#new? ⇒ Boolean
252 253 254 |
# File 'lib/mongo_mapper/document.rb', line 252 def new? read_attribute('_id').blank? || using_custom_id? end |
#save ⇒ Object
256 257 258 |
# File 'lib/mongo_mapper/document.rb', line 256 def save create_or_update end |
#save! ⇒ Object
260 261 262 |
# File 'lib/mongo_mapper/document.rb', line 260 def save! create_or_update || raise(DocumentNotValid.new(self)) end |