Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- acts_as_state_machine :initial => :pending
- state :passive
- state :pending, :enter => :make_activation_code
- state :active, :enter => :do_activate
- state :suspended
- state :deleted, :enter => :do_delete
- event :register do
- transitions :from => :passive, :to => :pending, :guard => Proc.new {|u| !(u.crypted_password.blank? && u.password.blank?) }
- end
- event :activate do
- transitions :from => :pending, :to => :active
- end
- event :suspend do
- transitions :from => [:passive, :pending, :active], :to => :suspended
- end
- event :delete do
- transitions :from => [:passive, :pending, :active, :suspended], :to => :deleted
- end
- event :unsuspend do
- transitions :from => :suspended, :to => :active, :guard => Proc.new {|u| !u.activated_at.blank? }
- transitions :from => :suspended, :to => :pending, :guard => Proc.new {|u| !u.activation_code.blank? }
- transitions :from => :suspended, :to => :passive
- end
Add Comment
Please, Sign In to add comment