Module: Mongo::Model::Crud

Defined in:
lib/mongo_db/model/crud.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#destroy(opts = {}) ⇒ Object



12
13
14
15
16
# File 'lib/mongo_db/model/crud.rb', line 12

def destroy opts = {}
  with_collection opts do |collection, opts|
    collection.destroy self, opts
  end
end

#destroy!(*args) ⇒ Object



18
19
20
# File 'lib/mongo_db/model/crud.rb', line 18

def destroy! *args
  destroy(*args) || raise(Mongo::Error, "can't destroy #{self.inspect}!")
end

#save(opts = {}) ⇒ Object



2
3
4
5
6
# File 'lib/mongo_db/model/crud.rb', line 2

def save opts = {}
  with_collection opts do |collection, opts|
    collection.save self, opts
  end
end

#save!(*args) ⇒ Object



8
9
10
# File 'lib/mongo_db/model/crud.rb', line 8

def save! *args
  save(*args) || raise(Mongo::Error, "can't save #{self.inspect}!")
end