Created
August 7, 2011 03:25
-
-
Save softwaregravy/1130024 to your computer and use it in GitHub Desktop.
State machine driving registrations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state_machine do | |
state :email, :exit => lambda {|reg| reg.errors.clear } | |
state :age, :exit => lambda {|reg| reg.errors.clear } | |
state :complete, :enter => :register_user | |
event :next do | |
transitions :from => :email, :to => :age, :guard => :guard_to_age | |
transitions :from => :age, :to => :complete, :guard => :guard_to_complete | |
# do not allow complete => complete | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment