Sha256: b0d29b4f41dc1bfb60b7e2830d0d0e41851ec6da95f0f19f6936a33f18145d1c
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
module NxtStateMachine class Transition include Transition::Interface def initialize(name, event:, from:, to:, state_machine:, context:, set_state_method:, &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 end attr_reader :name, :from, :to, :block, :event def prepare Callable.new( state_machine.send(set_state_method) ).bind( context ).call(state_machine.target(context), self) end def execute(&block) Transition::Proxy.new(event, state_machine,self, context).call(&block) rescue StandardError => error callback = state_machine.find_error_callback(error, self) raise unless callback Callable.new(callback).bind(context).call(error, self) end alias_method :with_around_callbacks, :execute def run_before_callbacks state_machine.run_before_callbacks(self, context) end def run_after_callbacks state_machine.run_after_callbacks(self, context) end private attr_reader :state_machine, :set_state_method, :context attr_writer :block end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nxt_state_machine-0.1.3 | lib/nxt_state_machine/transition.rb |
nxt_state_machine-0.1.2 | lib/nxt_state_machine/transition.rb |
nxt_state_machine-0.1.1 | lib/nxt_state_machine/transition.rb |