Created
January 17, 2012 21:50
-
-
Save prathe/1629153 to your computer and use it in GitHub Desktop.
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 :state, initial: :opened do | |
state :opened | |
state :confirmed | |
state :rejected | |
state :closed | |
event :confirm_it do | |
# only user | |
transition [:opened, :rejected] => :confirmed | |
end | |
event :unconfirm_it do | |
# only user | |
transition :confirmed => :opened | |
end | |
event :reject_it do | |
# only admin | |
transition [:opened, :confirmed] => :rejected | |
end | |
event :close_it do | |
# only admin | |
transition [:opened, :confirmed, :rejected] => :closed | |
end | |
after_transition :to => [:confirmed], :do => :set_confirmed | |
after_transition :to => [:rejected], :do => :increment_rejected_count | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment