Class: Artisan::CrudStrategy
- Inherits:
-
Object
- Object
- Artisan::CrudStrategy
- Defined in:
- lib/artisan/crud_strategy.rb
Class Method Summary collapse
- .create(model, callbacks, repository) ⇒ Object
- .update(model, model_attributes, user, callbacks) ⇒ Object
Class Method Details
.create(model, callbacks, repository) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/artisan/crud_strategy.rb', line 4 def self.create(model, callbacks, repository) if repository.save(model) callbacks.call(:success, model) else callbacks.call(:failure, model) end return model end |
.update(model, model_attributes, user, callbacks) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/artisan/crud_strategy.rb', line 13 def self.update(model, model_attributes, user, callbacks) if model.update_attributes(model_attributes) callbacks.call(:success, model) else callbacks.call(:failure, model) end return model end |