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, options = {}) ⇒ 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, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 14 def go_to_transition(action, = {}) return if @job.status.to_s.downcase == 'dead' transitions.on(action, state.to_s => action) @job.status = action if [:bundler] @job.bundler_status = action actor_notify_state_change(state, "preparing_app_bundle_install", action) else @job.bundler_status = nil machine.trigger(action) end end |
#machine ⇒ Object
27 28 29 30 31 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 27 def machine @machine ||= ComposableStateMachine::MachineWithExternalState.new( model, method(:state), method(:state=), state: @initial_state.to_s, callback_runner: self) @machine end |
#model ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 38 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
33 34 35 36 |
# File 'lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb', line 33 def transitions @transitions ||= ComposableStateMachine::Transitions.new @transitions end |