Closed domokos closed 1 year ago
Hi 👋
Thank you for this issue report.
I can confirm that any_state
works when a finite machine is created with the new
. So the following works fine:
fsm = FiniteMachine.new do
initial :green
event :slow, any_state => :yellow
event :stop, :yellow => :red
end
fsm.slow
fsm.current # => :yellow
When it fails is when using the define
or class definition for a finite machine:
FSM = FiniteMachine.define do
initial :green
event :slow, any_state => :yellow
event :stop, :yellow => :red
end
fsm = FSM.new
fsm.slow
fsm.current # => :green
The temporary fix is to use the FiniteMachine::ANY_STATE
directly:
FSM = FiniteMachine.define do
initial :green
event :slow, FiniteMachine::ANY_STATE => :yellow
event :stop, :yellow => :red
end
fsm = FSM.new
fsm.slow
fsm.current # => :green
The issue is that the any_state
and any_event
are converted to Proc
objects when called within define
block. I'll provide a fix shortly.
Describe the problem
Transition does not happen if any_state is used in the definition
Steps to reproduce the problem
Actual behaviour
Transition does not happen if any_state is used in the from definition
Expected behaviour
Transition should happen
Describe your environment
This worked fine with earlier ruby/finite_machine where I used the
event :turnoff, any: :off
notation. Bit me when I upgraded.