Closed rosskevin closed 9 years ago
This indeed seems to be a bug, but I think I'm going to switch to passing an options hash to the event methods, that way it is not order dependent.
Confirmed; pass it a boolean on the tail end of an arguments list and it gets eaten, eg.
(true, 0, false) => (true, 0)
, (99, "abc", true) => (99, "abc")
, etc.
I think this is unfortunately a works-as-designed:
From http://www.rubydoc.info/github/pluginaweek/state_machine/master/StateMachine/Machine:event:
park(..., run_action = true)
- Fires the “park” event, transitioning from the current state to the next valid state. If the last argument is a boolean, it will control whether the machine's action gets run.
(It's the .cancel()
itself that's swallowing the boolean.)
That feels...at least unexpected. Not hard to workaround, just really unexpected.
Agreed. I've personally tripped over it at least once myself; it's like you need to always put your args in a tuple or nested array to avoid the last-arg tag-check thing.
subscription.cancel!(true)
yieldstransition.args
emptysubscription.cancel!(true, 'foo')
yieldstransition.args
length 2# [true, 'foo']
subscription.cancel!('foo')
yieldstransition.args
length 1# ['foo']