Marshall's absolutely correct.
To clarify a little further: the #next! method is already defined on StateFu#binding, so rather than calling a method to trigger your action, you were calling a method which triggers the only possible transition, otherwise raises an error if there is more than one possible transition.
If you prefer to have one event name, you can do this:
class K
include StateFu
machine( :state ) do
state :step1 do
event :go, :to => :step2
end
state :step2 do
event :go, :to => :step3
end
state :step3 do
event :go, :to => :step4
end
end
end
>> k = K.new
>> k.go! :step2
=> #<StateFu::Transition:0x18cfc70 event=:go origin=:step1 target=:step2 args=[] options={}>
However, it's the event (not the state) which determines the possible transitions:
>> k.state.machine.events.first
=> #<StateFu::Event::13043290 @name=:go targets=[:step2, :step3, :step4] origins=[:step1, :step2, :step3]>
So in doing this, you make it possible to change from any state to any other - probably not what you intended - thus, Marshall's suggestion makes perfect sense.
Hope this helps you understand what went wrong a little better.
cheers,
David
--
cheers,
David Lee