Module: Gris::CrudHelpers
- Defined in:
- lib/gris/grape_extensions/crud_helpers.rb
Instance Method Summary collapse
- #create(type, options = {}) ⇒ Object
- #delete(instance, options = {}) ⇒ Object
- #permitted_params(options = {}) ⇒ Object
- #update(instance, options = {}) ⇒ Object
Instance Method Details
#create(type, options = {}) ⇒ Object
9 10 11 12 |
# File 'lib/gris/grape_extensions/crud_helpers.rb', line 9 def create(type, = {}) instance = type.create! [:from] present instance, with: [:with] end |
#delete(instance, options = {}) ⇒ Object
19 20 21 22 |
# File 'lib/gris/grape_extensions/crud_helpers.rb', line 19 def delete(instance, = {}) instance.destroy present instance, with: [:with] end |
#permitted_params(options = {}) ⇒ Object
24 25 26 27 |
# File 'lib/gris/grape_extensions/crud_helpers.rb', line 24 def permitted_params( = {}) = { include_missing: false }.merge() declared(params, ) end |
#update(instance, options = {}) ⇒ Object
14 15 16 17 |
# File 'lib/gris/grape_extensions/crud_helpers.rb', line 14 def update(instance, = {}) instance.update_attributes! [:from] present instance, with: [:with] end |