Module: SkinnyControllers::Diet
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/skinny_controllers/diet.rb
Constant Summary collapse
- ALLOWED_OPTIONS =
[ :model_class, :parent_class, :asociation_name, :model_params_key ].freeze
Instance Method Summary collapse
- #_lookup ⇒ Object
- #_options ⇒ Object
- #create_operation(user:, params_for_action: nil) ⇒ Object
-
#model ⇒ ActiveRecord::Base
abstraction for
operation.runuseful when there is no logic needed for deciding what to do with an operation or if there is no logic to decide which operation to use. -
#operation ⇒ Object
TODO: what if we want multiple operations per action?.
-
#operation_class ⇒ Class
Assumes the operation name from the controller name.
Instance Method Details
#_lookup ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/skinny_controllers/diet.rb', line 58 def _lookup @_lookup ||= Lookup.from_controller( controller_class: self.class, verb: verb_for_action, model_class: [:model_class] ) end |
#_options ⇒ Object
54 55 56 |
# File 'lib/skinny_controllers/diet.rb', line 54 def self.class. || {} end |
#create_operation(user:, params_for_action: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/skinny_controllers/diet.rb', line 22 def create_operation(user:, params_for_action: nil) operation_class.new( user, params, params_for_action, action_name, _lookup, ) end |
#model ⇒ ActiveRecord::Base
abstraction for operation.run useful when there is no logic needed for deciding what to do with an operation or if there is no logic to decide which operation to use
72 73 74 |
# File 'lib/skinny_controllers/diet.rb', line 72 def model @model ||= operation.run end |
#operation ⇒ Object
TODO: what if we want multiple operations per action?
36 37 38 39 40 41 42 43 44 |
# File 'lib/skinny_controllers/diet.rb', line 36 def operation @operation ||= operation_class.new( current_user, params, params_for_action, action_name, _lookup, ) end |
#operation_class ⇒ Class
Assumes the operation name from the controller name
50 51 52 |
# File 'lib/skinny_controllers/diet.rb', line 50 def operation_class _lookup.operation_class end |