Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "failure" callback to defined events #114

Open
jondecko opened this issue Dec 24, 2013 · 5 comments
Open

Add "failure" callback to defined events #114

jondecko opened this issue Dec 24, 2013 · 5 comments
Assignees
Labels

Comments

@jondecko
Copy link
Collaborator

Initial discussion started in the following issue ( #113 )

Like the success callback on events, we should have a matching failure callback. An event definition may look something like the following:

event :available, :failure => :reorder do
  transitions :to => :available, :from => [:out_of_stock], :guard => lambda { |product| product.in_stock > 0 }
end

The failure callback should take the following:

  • symbol or lambda block like many other callbacks within the gem
  • single callback or an array of callbacks like the rest of the gem

A few areas to consider where a failure condition may come into play

  • The state does not transition because you are moving from one state that can't move to another state (to -> from's are not valid)
  • A guard condition is hit preventing a successful transition
  • An on_transition scenario halts the transition from being successful. An exception may be raised within an on_transition callback.

@troessner - Let me know if anything looks out of line with the initial plan for this.

@troessner
Copy link
Owner

Excellent summary. One more thing: i think right now the "success" callback is more of an "execute at the end" callback. I dont think we are checking there for any success whatsoever. Just saying that we might need to change the flow there as well.

@jondecko
Copy link
Collaborator Author

Sounds good. I'll have to check for that condition when I crack into the code a bit more :)

@ghost ghost assigned jondecko Dec 26, 2013
@jondecko
Copy link
Collaborator Author

@troessner - Have not forgot about this but still have not had time to get into it. Just wanted to give you a heads up on this.

@troessner
Copy link
Owner

No problem, noted..:)

@pedromartinez
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants