+ aasm :column => :status, :no_direct_assignment => true do
+ state :pending, :initial => true
+ state :active
+ state :confirmed
+ state :suspended
+ state :deleted
+
+ # A normal account is active
+ event :activate do
+ transitions :from => :pending, :to => :active
+ end
+
+ # Used in test suite, not something that we would normally need to do.
+ if Rails.env.test?
+ event :deactivate do
+ transitions :from => :active, :to => :pending
+ end
+ end
+
+ # To confirm an account is used to override the spam scoring
+ event :confirm do
+ transitions :from => [:pending, :active, :suspended], :to => :confirmed
+ end
+
+ # To unconfirm an account is to make it subject to future spam scoring again
+ event :unconfirm do
+ transitions :from => :confirmed, :to => :active
+ end
+
+ # Accounts can be automatically suspended by spam_check
+ event :suspend do
+ transitions :from => [:pending, :active], :to => :suspended
+ end