class NxtStateMachine::Transition
Attributes
arguments[R]
block[RW]
context[R]
event[R]
from[R]
name[R]
options[R]
result[RW]
set_state_method[R]
state_machine[R]
to[R]
Public Class Methods
new(name, event:, from:, to:, state_machine:, context:, set_state_method:, arguments:, options:, &block)
click to toggle source
# File lib/nxt_state_machine/transition.rb, line 5 def initialize(name, event:, from:, to:, state_machine:, context:, set_state_method:, arguments:, options:, &block) @name = name @event = event @from = state_machine.states.resolve!(from) @to = state_machine.states.resolve!(to) @state_machine = state_machine @set_state_method = set_state_method @context = context @block = block @arguments = arguments @options = options @result = nil end
Public Instance Methods
execute(&block)
click to toggle source
This must be used in set_state method to actually execute the transition within the around callback chain
# File lib/nxt_state_machine/transition.rb, line 36 def execute(&block) self.result = Transition::Proxy.new(event, state_machine,self, context).call(&block) end
Also aliased as: with_around_callbacks
run_after_callbacks()
click to toggle source
# File lib/nxt_state_machine/transition.rb, line 46 def run_after_callbacks state_machine.run_after_callbacks(self, context) end
run_before_callbacks()
click to toggle source
# File lib/nxt_state_machine/transition.rb, line 42 def run_before_callbacks state_machine.run_before_callbacks(self, context) end
run_success_callbacks()
click to toggle source
# File lib/nxt_state_machine/transition.rb, line 50 def run_success_callbacks state_machine.run_success_callbacks(self, context) end
trigger()
click to toggle source
This triggers the set state method
# File lib/nxt_state_machine/transition.rb, line 22 def trigger Callable.new( state_machine.send(set_state_method) ).bind( context ).call(state_machine.target(context), self) rescue StandardError => error callback = state_machine.find_error_callback(error, self) raise unless callback Callable.new(callback).bind(context).call(error, self) end