workflow
workflow copied to clipboard
Callback on entering initial state
I'd like to run a callback when an object enters its initial state. For example:
class Article
include Workflow
workflow do
state :new
end
def on_new_entry
puts 'entered new'
end
end
Currently, workflow doesn't run the on_new_entry callback. Is this expected? If so, what's the best practice for running a callback on entering of an initial state?
Looking at https://github.com/geekq/workflow/blob/ba6946ba6711e2d255cc2fd5d28e6af3add3df36/lib/workflow.rb#L97, on entry is not called for the initial action, only when transitioning from one action to another.
I'd suggest defining a method with the state name, but that's tricky with an event called 'new'. You could always call it something else, like 'initial', and then you could have an initial method?