Module: MemoryModel::Base::Actions::ClassMethods
- Defined in:
- lib/memory_model/base/actions/class_methods.rb
Instance Method Summary collapse
- #create(attributes = {}) ⇒ Object
- #create!(attributes = {}) ⇒ Object
- #delete_all ⇒ Object
- #destroy_all ⇒ Object
Instance Method Details
#create(attributes = {}) ⇒ Object
6 7 8 |
# File 'lib/memory_model/base/actions/class_methods.rb', line 6 def create(attributes={}) new(attributes).tap(&:save) end |
#create!(attributes = {}) ⇒ Object
10 11 12 |
# File 'lib/memory_model/base/actions/class_methods.rb', line 10 def create!(attributes={}) new(attributes).tap(&:save!) end |
#delete_all ⇒ Object
14 15 16 17 18 |
# File 'lib/memory_model/base/actions/class_methods.rb', line 14 def delete_all count.tap do self.collection.clear end end |
#destroy_all ⇒ Object
20 21 22 |
# File 'lib/memory_model/base/actions/class_methods.rb', line 20 def destroy_all self.all.each(&:destroy) end |