Class: Operations::Task::Plan::ActionHandler

Inherits:
Object
  • Object
show all
Defined in:
app/models/operations/task/plan/action_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_stateObject

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

Returns:

  • (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