Module: SkinnyControllers::Diet

Extended by:
ActiveSupport::Concern
Defined in:
lib/skinny_controllers/diet.rb

Instance Method Summary collapse

Instance Method Details

#modelActiveRecord::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

Returns:

  • the model



30
31
32
# File 'lib/skinny_controllers/diet.rb', line 30

def model
  @model ||= operation.run
end

#operationObject

TODO: what if we want multiple operations per action?

Returns:

  • an instance of the operation with default parameters



12
13
14
# File 'lib/skinny_controllers/diet.rb', line 12

def operation
  @operation ||= operation_class.new(current_user, params)
end

#operation_classClass

Assumes the operation name from the controller name

Examples:

SomeObjectsController => Operation::SomeObject::Action


Returns:

  • the operation class for the model and verb



20
21
22
# File 'lib/skinny_controllers/diet.rb', line 20

def operation_class
  Lookup::Operation.from_controller(self.class.name, verb_for_action, model_class)
end