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
|
# File 'lib/carter/state_machine.rb', line 11
def init_states
state_machine :state, :initial => :active do
state :active, :processing, :failure, :success, :expired
event :checkout do
transition [:active, :failure] => :processing
end
event :succeeded do
transition :processing => :success
end
event :failed do
transition :processing => :failure
end
event :expire do
transition :active => :expired
end
after_transition :on => :succeeded, :do => :on_success
after_transition :on => :checkout, :do => :on_checkout
after_transition :on => :failed, :do => :on_failed
end
end
|