Class: Aldous::Controller::PreconditionsExecutionService
- Inherits:
-
Object
- Object
- Aldous::Controller::PreconditionsExecutionService
- Defined in:
- lib/aldous/controller/preconditions_execution_service.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
-
#initialize(action, controller) ⇒ PreconditionsExecutionService
constructor
A new instance of PreconditionsExecutionService.
- #perform ⇒ Object
Constructor Details
#initialize(action, 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, controller) @action = action @controller = controller end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
7 8 9 |
# File 'lib/aldous/controller/preconditions_execution_service.rb', line 7 def action @action 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 28 |
# File 'lib/aldous/controller/preconditions_execution_service.rb', line 14 def perform if action.respond_to?(:preconditions) && !action.preconditions.empty? action.preconditions.each do |precondition_class| # action here is actually an action wrapper hence the # action.controller_action below precondition = precondition_class.build(action.controller_action) precondition_result = precondition.perform if precondition_result.kind_of?(::Aldous::Respondable::Base) return [precondition, precondition_result] end end end [nil, nil] end |