Module: Authorization::AasmRoles
- Defined in:
- lib/branston/vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb
Defined Under Namespace
Modules: StatefulRolesClassMethods, StatefulRolesInstanceMethods
Constant Summary collapse
- STATEFUL_ROLES_CONSTANTS_DEFINED =
sorry for the C idiom
true
Class Method Summary collapse
Class Method Details
.included(recipient) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/branston/vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb', line 7 def self.included( recipient ) recipient.extend( StatefulRolesClassMethods ) recipient.class_eval do include StatefulRolesInstanceMethods include AASM aasm_column :state aasm_initial_state :initial => :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 aasm_event :register do transitions :from => :passive, :to => :pending, :guard => Proc.new {|u| !(u.crypted_password.blank? && u.password.blank?) } end aasm_event :activate do transitions :from => :pending, :to => :active end aasm_event :suspend do transitions :from => [:passive, :pending, :active], :to => :suspended end aasm_event :delete do transitions :from => [:passive, :pending, :active, :suspended], :to => :deleted end 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 end |