Module: MongoMapper::Plugins::Querying::InstanceMethods

Defined in:
lib/mongo_mapper/plugins/querying.rb

Instance Method Summary collapse

Instance Method Details

#deleteObject



209
210
211
212
# File 'lib/mongo_mapper/plugins/querying.rb', line 209

def delete
  @_destroyed = true
  self.class.delete(id) unless new?
end

#destroyObject



205
206
207
# File 'lib/mongo_mapper/plugins/querying.rb', line 205

def destroy
  delete
end

#save(options = {}) ⇒ Object



194
195
196
197
198
# File 'lib/mongo_mapper/plugins/querying.rb', line 194

def save(options={})
  options.assert_valid_keys(:validate, :safe)
  options.reverse_merge!(:validate => true)
  !options[:validate] || valid? ? create_or_update(options) : false
end

#save!(options = {}) ⇒ Object



200
201
202
203
# File 'lib/mongo_mapper/plugins/querying.rb', line 200

def save!(options={})
  options.assert_valid_keys(:safe)
  save(options) || raise(DocumentNotValid.new(self))
end