Class: Operations::Task::Plan::DecisionHandler
- Inherits:
-
Object
- Object
- Operations::Task::Plan::DecisionHandler
- Defined in:
- app/models/operations/task/plan/decision_handler.rb
Instance Method Summary collapse
- #call(task) ⇒ Object
- #condition(&condition) ⇒ Object
- #go_to(destination) ⇒ Object
- #if_false(state = nil, &handler) ⇒ Object
- #if_true(state = nil, &handler) ⇒ Object
- #immediate? ⇒ Boolean
-
#initialize(name, &config) ⇒ DecisionHandler
constructor
A new instance of DecisionHandler.
Constructor Details
#initialize(name, &config) ⇒ DecisionHandler
Returns a new instance of DecisionHandler.
2 3 4 5 6 7 8 9 |
# File 'app/models/operations/task/plan/decision_handler.rb', line 2 def initialize name, &config @name = name.to_sym @conditions = [] @destinations = [] @true_state = nil @false_state = nil instance_eval(&config) end |
Instance Method Details
#call(task) ⇒ Object
23 24 25 |
# File 'app/models/operations/task/plan/decision_handler.rb', line 23 def call(task) has_true_false_handlers? ? handle_single_condition(task) : handle_multiple_conditions(task) end |
#condition(&condition) ⇒ Object
13 14 15 |
# File 'app/models/operations/task/plan/decision_handler.rb', line 13 def condition(&condition) @conditions << condition end |
#go_to(destination) ⇒ Object
17 |
# File 'app/models/operations/task/plan/decision_handler.rb', line 17 def go_to(destination) = @destinations << destination |
#if_false(state = nil, &handler) ⇒ Object
21 |
# File 'app/models/operations/task/plan/decision_handler.rb', line 21 def if_false(state = nil, &handler) = @false_state = state || handler |
#if_true(state = nil, &handler) ⇒ Object
19 |
# File 'app/models/operations/task/plan/decision_handler.rb', line 19 def if_true(state = nil, &handler) = @true_state = state || handler |
#immediate? ⇒ Boolean
11 |
# File 'app/models/operations/task/plan/decision_handler.rb', line 11 def immediate? = true |