Class: CapistranoMulticonfigParallel::StateMachine
- Inherits:
-
Object
- Object
- CapistranoMulticonfigParallel::StateMachine
- Includes:
- ComposableStateMachine::CallbackRunner
- Defined in:
- lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb
Overview
class that handles the states of the celluloid worker executing the child process in a fork process
Instance Attribute Summary collapse
-
#actor ⇒ Object
Returns the value of attribute actor.
-
#initial_state ⇒ Object
Returns the value of attribute initial_state.
-
#job ⇒ Object
Returns the value of attribute job.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #go_to_transition(action) ⇒ Object
-
#initialize(job, actor) ⇒ StateMachine
constructor
A new instance of StateMachine.
- #machine ⇒ Object
- #model ⇒ Object
- #transitions ⇒ Object
Constructor Details
#initialize(job, actor) ⇒ StateMachine
Returns a new instance of StateMachine.
7 8 9 10 11 12 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 7 def initialize(job, actor) @job = job @actor = actor @initial_state = @job.status machine end |
Instance Attribute Details
#actor ⇒ Object
Returns the value of attribute actor.
5 6 7 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 5 def actor @actor end |
#initial_state ⇒ Object
Returns the value of attribute initial_state.
5 6 7 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 5 def initial_state @initial_state end |
#job ⇒ Object
Returns the value of attribute job.
5 6 7 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 5 def job @job end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 5 def state @state end |
Instance Method Details
#go_to_transition(action) ⇒ Object
14 15 16 17 18 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 14 def go_to_transition(action) transitions.on(action, state.to_s => action) @job.status = action machine.trigger(action) end |
#machine ⇒ Object
20 21 22 23 24 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 20 def machine @machine ||= ComposableStateMachine::MachineWithExternalState.new( model, method(:state), method(:state=), state: @initial_state.to_s, callback_runner: self) @machine end |
#model ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 31 def model ComposableStateMachine.model( transitions: transitions, behaviors: { enter: { any: proc do |current_state, event, new_state| actor_notify_state_change(current_state, event, new_state) end } }, initial_state: @initial_state ) end |
#transitions ⇒ Object
26 27 28 29 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 26 def transitions @transitions ||= ComposableStateMachine::Transitions.new @transitions end |