Closed timeon closed 5 years ago
The question is, what would such event do beyond changing the state? Is it the same or different for all "from" states?
If it is different for every "from" state, you will need to name events differently to provide a separate handler for every transition.
If it is the same, then you can just define a plane method
class Article
include Workflow
def reset!
self[:workflow_state] = :my_first_state
save!
end
...
If it is almost the same, but you would like to take advantage of on_exit transition hooks, you could run it directly:
run_on_exit(current_state, spec.states[:my_first_state], nil)
For example, at any state, I would like to be reset the workflow to it's first state.