Class: Operations::Task::Plan::ActionHandler
- Inherits:
-
Object
- Object
- Operations::Task::Plan::ActionHandler
- Defined in:
- app/models/operations/task/plan/action_handler.rb
Instance Attribute Summary collapse
-
#next_state ⇒ Object
Returns the value of attribute next_state.
Instance Method Summary collapse
- #call(task) ⇒ Object
- #immediate? ⇒ Boolean
-
#initialize(name, &action) ⇒ ActionHandler
constructor
A new instance of ActionHandler.
- #then(next_state) ⇒ Object
Constructor Details
#initialize(name, &action) ⇒ ActionHandler
Returns a new instance of ActionHandler.
4 5 6 7 8 |
# File 'app/models/operations/task/plan/action_handler.rb', line 4 def initialize name, &action @name = name.to_sym @action = action @next_state = nil end |
Instance Attribute Details
#next_state ⇒ Object
Returns the value of attribute next_state.
2 3 4 |
# File 'app/models/operations/task/plan/action_handler.rb', line 2 def next_state @next_state end |
Instance Method Details
#call(task) ⇒ Object
16 17 18 19 |
# File 'app/models/operations/task/plan/action_handler.rb', line 16 def call(task) task.instance_exec(&@action) task.go_to @next_state end |
#immediate? ⇒ Boolean
14 |
# File 'app/models/operations/task/plan/action_handler.rb', line 14 def immediate? = true |
#then(next_state) ⇒ Object
10 11 12 |
# File 'app/models/operations/task/plan/action_handler.rb', line 10 def then next_state @next_state = next_state end |