pluginaweek / state_machine

Adds support for creating state machines for attributes on any Ruby class
http://www.pluginaweek.org
MIT License
3.74k stars 505 forks source link

Abort transition using around_transition #352

Open davidpatters0n opened 7 years ago

davidpatters0n commented 7 years ago

Is it possible to abort/halt a transition whilst inside a around_transition. The example I have here is:

around_transition do |cost_item, transition, block|
  if ticket.access_keys.any?(&:full?)
    # abort transition!
    false
  else
    block.call
    ticket.send(:redeem_access_key, transition)
  end
end

Is returning false sufficient. According to the readme and the rubydoc there is no mention of this:

http://www.rubydoc.info/github/pluginaweek/state_machine/StateMachine%2FMachine%3Aaround_transition