Created
May 16, 2012 20:34
-
-
Save kinsteronline/2713730 to your computer and use it in GitHub Desktop.
Authorization states in a Proc
This file contains hidden or 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
class Customer < AR::Base | |
authorization_states = Proc.new do | |
event :start_authorizing do | |
transition all => :authorizing | |
end | |
event :finish_authorizing do | |
transition :authorizing => :authorized | |
end | |
event :fail_to_authorize do | |
transition [:authorizing, :unauthorized] => :auth_failure | |
end | |
event :deauthorize do | |
transition all => :unauthorized | |
end | |
end | |
state_machine :facebook_auth_state, { | |
:initial => :unauthorized, | |
:namespace => 'facebook' | |
}, &authorization_states | |
state_machine :twitter_auth_state, { | |
:initial => :unauthorized, | |
:namespace => 'twitter' | |
}, &authorization_states | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment