lib/authorization/stateful_roles.rb in jeremydurham-restful_authentication-1.1.4 vs lib/authorization/stateful_roles.rb in jeremydurham-restful_authentication-1.1.5
- old
+ new
@@ -5,35 +5,37 @@
end
def self.included( recipient )
recipient.extend( StatefulRolesClassMethods )
recipient.class_eval do
+ include AASM
include StatefulRolesInstanceMethods
- 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
+ aasm_column :state
+ aasm_initial_state :pending
+ aasm_state :passive
+ aasm_state :pending, :enter => :make_activation_code
+ aasm_state :active, :enter => :do_activate
+ aasm_state :suspended
+ aasm_state :deleted, :enter => :do_delete
- event :register do
+ aasm_event :register do
transitions :from => :passive, :to => :pending, :guard => Proc.new {|u| !(u.crypted_password.blank? && u.password.blank?) }
end
- event :activate do
+ aasm_event :activate do
transitions :from => :pending, :to => :active
end
- event :suspend do
+ aasm_event :suspend do
transitions :from => [:passive, :pending, :active], :to => :suspended
end
- event :delete do
+ aasm_event :delete do
transitions :from => [:passive, :pending, :active, :suspended], :to => :deleted
end
- event :unsuspend do
+ aasm_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
end