Class: Aldous::Controller::PreconditionsExecutionService
- Inherits:
-
Object
- Object
- Aldous::Controller::PreconditionsExecutionService
- Defined in:
- lib/aldous/controller/preconditions_execution_service.rb
Instance Attribute Summary collapse
-
#action_wrapper ⇒ Object
readonly
Returns the value of attribute action_wrapper.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
-
#initialize(action_wrapper, controller) ⇒ PreconditionsExecutionService
constructor
A new instance of PreconditionsExecutionService.
- #perform ⇒ Object
Constructor Details
#initialize(action_wrapper, controller) ⇒ PreconditionsExecutionService
Returns a new instance of PreconditionsExecutionService.
9 10 11 12 |
# File 'lib/aldous/controller/preconditions_execution_service.rb', line 9 def initialize(action_wrapper, controller) @action_wrapper = action_wrapper @controller = controller end |
Instance Attribute Details
#action_wrapper ⇒ Object (readonly)
Returns the value of attribute action_wrapper.
7 8 9 |
# File 'lib/aldous/controller/preconditions_execution_service.rb', line 7 def action_wrapper @action_wrapper end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
7 8 9 |
# File 'lib/aldous/controller/preconditions_execution_service.rb', line 7 def controller @controller end |
Instance Method Details
#perform ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/aldous/controller/preconditions_execution_service.rb', line 14 def perform if action_wrapper.respond_to?(:preconditions) && !action_wrapper.preconditions.empty? action_wrapper.preconditions.each do |precondition_class| action = action_wrapper.controller_action precondition = precondition_class.build(action, controller, action.view_builder) precondition_result = precondition.perform if precondition_result.kind_of?(::Aldous::Respondable::Base) return [precondition, precondition_result] end end end [nil, nil] end |