Module: Mongo::Model::Crud
- Defined in:
- lib/mongo/model/crud.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #destroy(options = {}) ⇒ Object
- #destroy!(*args) ⇒ Object
- #save(options = {}) ⇒ Object
- #save!(*args) ⇒ Object
Instance Method Details
#destroy(options = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/mongo/model/crud.rb', line 12 def destroy = {} with_collection do |collection, | collection.destroy self, end end |
#destroy!(*args) ⇒ Object
18 19 20 |
# File 'lib/mongo/model/crud.rb', line 18 def destroy! *args destroy(*args) || raise(Mongo::Error, "can't destroy #{self.inspect}!") end |
#save(options = {}) ⇒ Object
2 3 4 5 6 |
# File 'lib/mongo/model/crud.rb', line 2 def save = {} with_collection do |collection, | collection.save self, end end |
#save!(*args) ⇒ Object
8 9 10 |
# File 'lib/mongo/model/crud.rb', line 8 def save! *args save(*args) || raise(Mongo::Error, "can't save #{self.inspect}!") end |