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

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

Instance Method Summary collapse

Instance Method Details

#deleteObject



150
151
152
153
# File 'lib/mongo_mapper/plugins/querying.rb', line 150

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

#destroyObject



146
147
148
# File 'lib/mongo_mapper/plugins/querying.rb', line 146

def destroy
  delete
end

#save(options = {}) ⇒ Object



135
136
137
138
139
# File 'lib/mongo_mapper/plugins/querying.rb', line 135

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



141
142
143
144
# File 'lib/mongo_mapper/plugins/querying.rb', line 141

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