Module: Accountable::Accountor::States::AasmTraits

Defined in:
lib/accountable/accountor/states/aasm_traits.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/accountable/accountor/states/aasm_traits.rb', line 4

def self.included( base )
  base.class_eval do
    include AASM
    include StateMachineInstanceMethods
    
    aasm_column :status
    aasm_initial_state :passive
    aasm_state :passive
    aasm_state :active, :enter => :do_activate
    aasm_state :suspended, :enter => :do_suspend

    aasm_event :activate do
      transitions :from => :passive, :to => :active
    end
    aasm_event :suspend do
      transitions :from => [:passive, :active], :to => :suspended
    end
    aasm_event :unsuspend do
      transitions :from => :suspended, :to => :active
    end
  end
end