aasm 4.0.3 → 4.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +7 -7
- data/aasm.gemspec +5 -9
- data/lib/aasm.rb +13 -15
- data/lib/aasm/aasm.rb +0 -18
- data/lib/aasm/base.rb +1 -1
- data/lib/aasm/{event.rb → core/event.rb} +3 -3
- data/lib/aasm/{state.rb → core/state.rb} +1 -1
- data/lib/aasm/{transition.rb → core/transition.rb} +1 -1
- data/lib/aasm/persistence.rb +17 -11
- data/lib/aasm/persistence/active_record_persistence.rb +6 -9
- data/lib/aasm/persistence/mongoid_persistence.rb +4 -2
- data/lib/aasm/persistence/plain_persistence.rb +24 -0
- data/lib/aasm/persistence/sequel_persistence.rb +2 -0
- data/lib/aasm/state_machine.rb +1 -1
- data/lib/aasm/version.rb +1 -1
- data/spec/database.rb +5 -1
- data/spec/models/callbacks/basic.rb +62 -0
- data/spec/models/callbacks/guard_within_block.rb +66 -0
- data/spec/models/callbacks/with_args.rb +45 -0
- data/spec/models/callbacks/with_state_args.rb +26 -0
- data/spec/models/persistence.rb +61 -1
- data/spec/unit/callbacks_spec.rb +35 -32
- data/spec/unit/event_spec.rb +6 -6
- data/spec/unit/memory_leak_spec.rb +12 -12
- data/spec/unit/persistence/active_record_persistence_spec.rb +12 -36
- data/spec/unit/state_spec.rb +2 -2
- data/spec/unit/transition_spec.rb +23 -23
- metadata +20 -51
- data/spec/models/callback_new_dsl.rb +0 -129
- data/spec/models/guard_within_block.rb +0 -64
data/spec/unit/state_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe AASM::State do
|
3
|
+
describe AASM::Core::State do
|
4
4
|
before(:each) do
|
5
5
|
@name = :astate
|
6
6
|
@options = { :crazy_custom_key => 'key' }
|
7
7
|
end
|
8
8
|
|
9
9
|
def new_state(options={})
|
10
|
-
AASM::State.new(@name, Conversation, @options.merge(options))
|
10
|
+
AASM::Core::State.new(@name, Conversation, @options.merge(options))
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should set the name' do
|
@@ -51,10 +51,10 @@ end
|
|
51
51
|
describe 'blocks' do
|
52
52
|
end
|
53
53
|
|
54
|
-
describe AASM::Transition do
|
54
|
+
describe AASM::Core::Transition do
|
55
55
|
it 'should set from, to, and opts attr readers' do
|
56
56
|
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
57
|
-
st = AASM::Transition.new(opts)
|
57
|
+
st = AASM::Core::Transition.new(opts)
|
58
58
|
|
59
59
|
expect(st.from).to eq(opts[:from])
|
60
60
|
expect(st.to).to eq(opts[:to])
|
@@ -63,7 +63,7 @@ describe AASM::Transition do
|
|
63
63
|
|
64
64
|
it 'should set on_transition with deprecation warning' do
|
65
65
|
opts = {:from => 'foo', :to => 'bar'}
|
66
|
-
st = AASM::Transition.allocate
|
66
|
+
st = AASM::Core::Transition.allocate
|
67
67
|
st.should_receive(:warn).with('[DEPRECATION] :on_transition is deprecated, use :after instead')
|
68
68
|
|
69
69
|
st.send :initialize, opts do
|
@@ -76,7 +76,7 @@ describe AASM::Transition do
|
|
76
76
|
|
77
77
|
it 'should set after and guard from dsl' do
|
78
78
|
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
79
|
-
st = AASM::Transition.new(opts) do
|
79
|
+
st = AASM::Core::Transition.new(opts) do
|
80
80
|
guard :gg
|
81
81
|
after :after_callback
|
82
82
|
end
|
@@ -87,7 +87,7 @@ describe AASM::Transition do
|
|
87
87
|
|
88
88
|
it 'should pass equality check if from and to are the same' do
|
89
89
|
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
90
|
-
st = AASM::Transition.new(opts)
|
90
|
+
st = AASM::Core::Transition.new(opts)
|
91
91
|
|
92
92
|
obj = double('object')
|
93
93
|
allow(obj).to receive(:from).and_return(opts[:from])
|
@@ -98,7 +98,7 @@ describe AASM::Transition do
|
|
98
98
|
|
99
99
|
it 'should fail equality check if from are not the same' do
|
100
100
|
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
101
|
-
st = AASM::Transition.new(opts)
|
101
|
+
st = AASM::Core::Transition.new(opts)
|
102
102
|
|
103
103
|
obj = double('object')
|
104
104
|
allow(obj).to receive(:from).and_return('blah')
|
@@ -109,7 +109,7 @@ describe AASM::Transition do
|
|
109
109
|
|
110
110
|
it 'should fail equality check if to are not the same' do
|
111
111
|
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
112
|
-
st = AASM::Transition.new(opts)
|
112
|
+
st = AASM::Core::Transition.new(opts)
|
113
113
|
|
114
114
|
obj = double('object')
|
115
115
|
allow(obj).to receive(:from).and_return(opts[:from])
|
@@ -119,17 +119,17 @@ describe AASM::Transition do
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
describe AASM::Transition, '- when performing guard checks' do
|
122
|
+
describe AASM::Core::Transition, '- when performing guard checks' do
|
123
123
|
it 'should return true of there is no guard' do
|
124
124
|
opts = {:from => 'foo', :to => 'bar'}
|
125
|
-
st = AASM::Transition.new(opts)
|
125
|
+
st = AASM::Core::Transition.new(opts)
|
126
126
|
|
127
127
|
expect(st.allowed?(nil)).to be_true
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'should call the method on the object if guard is a symbol' do
|
131
131
|
opts = {:from => 'foo', :to => 'bar', :guard => :test}
|
132
|
-
st = AASM::Transition.new(opts)
|
132
|
+
st = AASM::Core::Transition.new(opts)
|
133
133
|
|
134
134
|
obj = double('object')
|
135
135
|
expect(obj).to receive(:test)
|
@@ -139,7 +139,7 @@ describe AASM::Transition, '- when performing guard checks' do
|
|
139
139
|
|
140
140
|
it 'should call the method on the object if unless is a symbol' do
|
141
141
|
opts = {:from => 'foo', :to => 'bar', :unless => :test}
|
142
|
-
st = AASM::Transition.new(opts)
|
142
|
+
st = AASM::Core::Transition.new(opts)
|
143
143
|
|
144
144
|
obj = double('object')
|
145
145
|
expect(obj).to receive(:test)
|
@@ -149,7 +149,7 @@ describe AASM::Transition, '- when performing guard checks' do
|
|
149
149
|
|
150
150
|
it 'should call the method on the object if guard is a string' do
|
151
151
|
opts = {:from => 'foo', :to => 'bar', :guard => 'test'}
|
152
|
-
st = AASM::Transition.new(opts)
|
152
|
+
st = AASM::Core::Transition.new(opts)
|
153
153
|
|
154
154
|
obj = double('object')
|
155
155
|
expect(obj).to receive(:test)
|
@@ -159,7 +159,7 @@ describe AASM::Transition, '- when performing guard checks' do
|
|
159
159
|
|
160
160
|
it 'should call the method on the object if unless is a string' do
|
161
161
|
opts = {:from => 'foo', :to => 'bar', :unless => 'test'}
|
162
|
-
st = AASM::Transition.new(opts)
|
162
|
+
st = AASM::Core::Transition.new(opts)
|
163
163
|
|
164
164
|
obj = double('object')
|
165
165
|
expect(obj).to receive(:test)
|
@@ -169,7 +169,7 @@ describe AASM::Transition, '- when performing guard checks' do
|
|
169
169
|
|
170
170
|
it 'should call the proc passing the object if the guard is a proc' do
|
171
171
|
opts = {:from => 'foo', :to => 'bar', :guard => Proc.new { test }}
|
172
|
-
st = AASM::Transition.new(opts)
|
172
|
+
st = AASM::Core::Transition.new(opts)
|
173
173
|
|
174
174
|
obj = double('object')
|
175
175
|
expect(obj).to receive(:test)
|
@@ -178,10 +178,10 @@ describe AASM::Transition, '- when performing guard checks' do
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
181
|
-
describe AASM::Transition, '- when executing the transition with a Proc' do
|
181
|
+
describe AASM::Core::Transition, '- when executing the transition with a Proc' do
|
182
182
|
it 'should call a Proc on the object with args' do
|
183
183
|
opts = {:from => 'foo', :to => 'bar', :after => Proc.new {|a| test(a) }}
|
184
|
-
st = AASM::Transition.new(opts)
|
184
|
+
st = AASM::Core::Transition.new(opts)
|
185
185
|
args = {:arg1 => '1', :arg2 => '2'}
|
186
186
|
obj = double('object', :aasm => 'aasm')
|
187
187
|
|
@@ -197,7 +197,7 @@ describe AASM::Transition, '- when executing the transition with a Proc' do
|
|
197
197
|
prc = Proc.new { prc_object = self }
|
198
198
|
|
199
199
|
opts = {:from => 'foo', :to => 'bar', :after => prc }
|
200
|
-
st = AASM::Transition.new(opts)
|
200
|
+
st = AASM::Core::Transition.new(opts)
|
201
201
|
args = {:arg1 => '1', :arg2 => '2'}
|
202
202
|
obj = double('object', :aasm => 'aasm')
|
203
203
|
|
@@ -206,10 +206,10 @@ describe AASM::Transition, '- when executing the transition with a Proc' do
|
|
206
206
|
end
|
207
207
|
end
|
208
208
|
|
209
|
-
describe AASM::Transition, '- when executing the transition with an :after method call' do
|
209
|
+
describe AASM::Core::Transition, '- when executing the transition with an :after method call' do
|
210
210
|
it 'should accept a String for the method name' do
|
211
211
|
opts = {:from => 'foo', :to => 'bar', :after => 'test'}
|
212
|
-
st = AASM::Transition.new(opts)
|
212
|
+
st = AASM::Core::Transition.new(opts)
|
213
213
|
args = {:arg1 => '1', :arg2 => '2'}
|
214
214
|
obj = double('object', :aasm => 'aasm')
|
215
215
|
|
@@ -220,7 +220,7 @@ describe AASM::Transition, '- when executing the transition with an :after metho
|
|
220
220
|
|
221
221
|
it 'should accept a Symbol for the method name' do
|
222
222
|
opts = {:from => 'foo', :to => 'bar', :after => :test}
|
223
|
-
st = AASM::Transition.new(opts)
|
223
|
+
st = AASM::Core::Transition.new(opts)
|
224
224
|
args = {:arg1 => '1', :arg2 => '2'}
|
225
225
|
obj = double('object', :aasm => 'aasm')
|
226
226
|
|
@@ -231,7 +231,7 @@ describe AASM::Transition, '- when executing the transition with an :after metho
|
|
231
231
|
|
232
232
|
it 'should pass args if the target method accepts them' do
|
233
233
|
opts = {:from => 'foo', :to => 'bar', :after => :test}
|
234
|
-
st = AASM::Transition.new(opts)
|
234
|
+
st = AASM::Core::Transition.new(opts)
|
235
235
|
args = {:arg1 => '1', :arg2 => '2'}
|
236
236
|
obj = double('object', :aasm => 'aasm')
|
237
237
|
|
@@ -246,7 +246,7 @@ describe AASM::Transition, '- when executing the transition with an :after metho
|
|
246
246
|
|
247
247
|
it 'should NOT pass args if the target method does NOT accept them' do
|
248
248
|
opts = {:from => 'foo', :to => 'bar', :after => :test}
|
249
|
-
st = AASM::Transition.new(opts)
|
249
|
+
st = AASM::Core::Transition.new(opts)
|
250
250
|
args = {:arg1 => '1', :arg2 => '2'}
|
251
251
|
obj = double('object', :aasm => 'aasm')
|
252
252
|
|
@@ -261,7 +261,7 @@ describe AASM::Transition, '- when executing the transition with an :after metho
|
|
261
261
|
|
262
262
|
it 'should allow accessing the from_state and the to_state' do
|
263
263
|
opts = {:from => 'foo', :to => 'bar', :after => :test}
|
264
|
-
transition = AASM::Transition.new(opts)
|
264
|
+
transition = AASM::Core::Transition.new(opts)
|
265
265
|
args = {:arg1 => '1', :arg2 => '2'}
|
266
266
|
obj = double('object', :aasm => AASM::InstanceBase.new('object'))
|
267
267
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aasm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Barron
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -43,59 +43,23 @@ dependencies:
|
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rspec
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '2.14'
|
50
|
-
type: :development
|
51
|
-
prerelease: false
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - "~>"
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: '2.14'
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: rr
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - ">="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0'
|
64
|
-
type: :development
|
65
|
-
prerelease: false
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
46
|
requirements:
|
68
47
|
- - ">="
|
69
48
|
- !ruby/object:Gem::Version
|
70
|
-
version: '
|
71
|
-
-
|
72
|
-
name: minitest
|
73
|
-
requirement: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
75
|
-
- - ">="
|
49
|
+
version: '2.14'
|
50
|
+
- - "<"
|
76
51
|
- !ruby/object:Gem::Version
|
77
|
-
version: '
|
52
|
+
version: '2.99'
|
78
53
|
type: :development
|
79
54
|
prerelease: false
|
80
55
|
version_requirements: !ruby/object:Gem::Requirement
|
81
56
|
requirements:
|
82
57
|
- - ">="
|
83
58
|
- !ruby/object:Gem::Version
|
84
|
-
version: '
|
85
|
-
-
|
86
|
-
name: mime-types
|
87
|
-
requirement: !ruby/object:Gem::Requirement
|
88
|
-
requirements:
|
89
|
-
- - "~>"
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: '1.25'
|
92
|
-
type: :development
|
93
|
-
prerelease: false
|
94
|
-
version_requirements: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
- - "~>"
|
59
|
+
version: '2.14'
|
60
|
+
- - "<"
|
97
61
|
- !ruby/object:Gem::Version
|
98
|
-
version: '
|
62
|
+
version: '2.99'
|
99
63
|
description: AASM is a continuation of the acts as state machine rails plugin, built
|
100
64
|
for plain Ruby objects.
|
101
65
|
email: scott@elitists.net, ttilley@gmail.com, aasm@mt7.de
|
@@ -124,19 +88,20 @@ files:
|
|
124
88
|
- lib/aasm/aasm.rb
|
125
89
|
- lib/aasm/base.rb
|
126
90
|
- lib/aasm/configuration.rb
|
91
|
+
- lib/aasm/core/event.rb
|
92
|
+
- lib/aasm/core/state.rb
|
93
|
+
- lib/aasm/core/transition.rb
|
127
94
|
- lib/aasm/dsl_helper.rb
|
128
95
|
- lib/aasm/errors.rb
|
129
|
-
- lib/aasm/event.rb
|
130
96
|
- lib/aasm/instance_base.rb
|
131
97
|
- lib/aasm/localizer.rb
|
132
98
|
- lib/aasm/persistence.rb
|
133
99
|
- lib/aasm/persistence/active_record_persistence.rb
|
134
100
|
- lib/aasm/persistence/base.rb
|
135
101
|
- lib/aasm/persistence/mongoid_persistence.rb
|
102
|
+
- lib/aasm/persistence/plain_persistence.rb
|
136
103
|
- lib/aasm/persistence/sequel_persistence.rb
|
137
|
-
- lib/aasm/state.rb
|
138
104
|
- lib/aasm/state_machine.rb
|
139
|
-
- lib/aasm/transition.rb
|
140
105
|
- lib/aasm/version.rb
|
141
106
|
- spec/database.rb
|
142
107
|
- spec/database.yml
|
@@ -146,13 +111,15 @@ files:
|
|
146
111
|
- spec/models/argument.rb
|
147
112
|
- spec/models/auth_machine.rb
|
148
113
|
- spec/models/bar.rb
|
149
|
-
- spec/models/
|
114
|
+
- spec/models/callbacks/basic.rb
|
115
|
+
- spec/models/callbacks/guard_within_block.rb
|
150
116
|
- spec/models/callbacks/multiple_transitions_transition_guard.rb
|
117
|
+
- spec/models/callbacks/with_args.rb
|
118
|
+
- spec/models/callbacks/with_state_args.rb
|
151
119
|
- spec/models/conversation.rb
|
152
120
|
- spec/models/double_definer.rb
|
153
121
|
- spec/models/father.rb
|
154
122
|
- spec/models/foo.rb
|
155
|
-
- spec/models/guard_within_block.rb
|
156
123
|
- spec/models/guardian.rb
|
157
124
|
- spec/models/invalid_persistor.rb
|
158
125
|
- spec/models/mongoid/no_scope_mongoid.rb
|
@@ -222,13 +189,15 @@ test_files:
|
|
222
189
|
- spec/models/argument.rb
|
223
190
|
- spec/models/auth_machine.rb
|
224
191
|
- spec/models/bar.rb
|
225
|
-
- spec/models/
|
192
|
+
- spec/models/callbacks/basic.rb
|
193
|
+
- spec/models/callbacks/guard_within_block.rb
|
226
194
|
- spec/models/callbacks/multiple_transitions_transition_guard.rb
|
195
|
+
- spec/models/callbacks/with_args.rb
|
196
|
+
- spec/models/callbacks/with_state_args.rb
|
227
197
|
- spec/models/conversation.rb
|
228
198
|
- spec/models/double_definer.rb
|
229
199
|
- spec/models/father.rb
|
230
200
|
- spec/models/foo.rb
|
231
|
-
- spec/models/guard_within_block.rb
|
232
201
|
- spec/models/guardian.rb
|
233
202
|
- spec/models/invalid_persistor.rb
|
234
203
|
- spec/models/mongoid/no_scope_mongoid.rb
|
@@ -1,129 +0,0 @@
|
|
1
|
-
class CallbackNewDsl
|
2
|
-
include AASM
|
3
|
-
|
4
|
-
def initialize(options={})
|
5
|
-
@fail_event_guard = options[:fail_event_guard]
|
6
|
-
@fail_transition_guard = options[:fail_transition_guard]
|
7
|
-
@log = options[:log]
|
8
|
-
end
|
9
|
-
|
10
|
-
aasm do
|
11
|
-
state :open, :initial => true,
|
12
|
-
:before_enter => :before_enter_open,
|
13
|
-
:enter => :enter_open,
|
14
|
-
:after_enter => :after_enter_open,
|
15
|
-
:before_exit => :before_exit_open,
|
16
|
-
:exit => :exit_open,
|
17
|
-
:after_exit => :after_exit_open
|
18
|
-
|
19
|
-
state :closed,
|
20
|
-
:before_enter => :before_enter_closed,
|
21
|
-
:enter => :enter_closed,
|
22
|
-
:after_enter => :after_enter_closed,
|
23
|
-
:before_exit => :before_exit_closed,
|
24
|
-
:exit => :exit_closed,
|
25
|
-
:after_exit => :after_exit_closed
|
26
|
-
|
27
|
-
event :close, :before => :before, :after => :after, :guard => :event_guard do
|
28
|
-
transitions :to => :closed, :from => [:open], :guard => :transition_guard, :after => :transitioning
|
29
|
-
end
|
30
|
-
|
31
|
-
event :open, :before => :before, :after => :after do
|
32
|
-
transitions :to => :open, :from => :closed
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def log(text)
|
37
|
-
puts text if @log
|
38
|
-
end
|
39
|
-
|
40
|
-
def before_enter_open; log('before_enter_open'); end
|
41
|
-
def enter_open; log('enter_open'); end
|
42
|
-
def before_exit_open; log('before_exit_open'); end
|
43
|
-
def after_enter_open; log('after_enter_open'); end
|
44
|
-
def exit_open; log('exit_open'); end
|
45
|
-
def after_exit_open; log('after_exit_open'); end
|
46
|
-
|
47
|
-
def before_enter_closed; log('before_enter_closed'); end
|
48
|
-
def enter_closed; log('enter_closed'); end
|
49
|
-
def before_exit_closed; log('before_exit_closed'); end
|
50
|
-
def exit_closed; log('exit_closed'); end
|
51
|
-
def after_enter_closed; log('after_enter_closed'); end
|
52
|
-
def after_exit_closed; log('after_exit_closed'); end
|
53
|
-
|
54
|
-
def event_guard; log('event_guard'); !@fail_event_guard; end
|
55
|
-
def transition_guard; log('transition_guard'); !@fail_transition_guard; end
|
56
|
-
def transitioning; log('transitioning'); end
|
57
|
-
|
58
|
-
def before; log('before'); end
|
59
|
-
def after; log('after'); end
|
60
|
-
end
|
61
|
-
|
62
|
-
class CallbackNewDslArgs
|
63
|
-
include AASM
|
64
|
-
|
65
|
-
aasm do
|
66
|
-
state :open, :initial => true,
|
67
|
-
:before_enter => :before_enter_open,
|
68
|
-
:after_enter => :after_enter_open,
|
69
|
-
:before_exit => :before_exit_open,
|
70
|
-
:after_exit => :after_exit_open
|
71
|
-
|
72
|
-
state :closed,
|
73
|
-
:before_enter => :before_enter_closed,
|
74
|
-
:after_enter => :after_enter_closed,
|
75
|
-
:before_exit => :before_exit_closed,
|
76
|
-
:after_exit => :after_exit_closed
|
77
|
-
|
78
|
-
event :close, :before => :before, :after => :after do
|
79
|
-
transitions :to => :closed, :from => [:open], :after => :transition_proc
|
80
|
-
end
|
81
|
-
|
82
|
-
event :open, :before => :before, :after => :after do
|
83
|
-
transitions :to => :open, :from => :closed
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def log(text)
|
88
|
-
# puts text
|
89
|
-
end
|
90
|
-
|
91
|
-
def before_enter_open; log('before_enter_open'); end
|
92
|
-
def before_exit_open; log('before_exit_open'); end
|
93
|
-
def after_enter_open; log('after_enter_open'); end
|
94
|
-
def after_exit_open; log('after_exit_open'); end
|
95
|
-
|
96
|
-
def before_enter_closed; log('before_enter_closed'); end
|
97
|
-
def before_exit_closed; log('before_enter_closed'); end
|
98
|
-
def after_enter_closed; log('after_enter_closed'); end
|
99
|
-
def after_exit_closed; log('after_exit_closed'); end
|
100
|
-
|
101
|
-
def before(*args); log('before'); end
|
102
|
-
def transition_proc(arg1, arg2); log('transition_proc'); end
|
103
|
-
def after(*args); log('after'); end
|
104
|
-
end
|
105
|
-
|
106
|
-
class CallbackWithStateArg
|
107
|
-
|
108
|
-
include AASM
|
109
|
-
|
110
|
-
aasm do
|
111
|
-
state :open, :inital => true
|
112
|
-
state :closed
|
113
|
-
state :out_to_lunch
|
114
|
-
|
115
|
-
event :close, :before => :before_method, :after => :after_method do
|
116
|
-
transitions :to => :closed, :from => [:open], :after => :transition_method
|
117
|
-
transitions :to => :out_to_lunch, :from => [:open], :after => :transition_method2
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def before_method(arg); end
|
122
|
-
|
123
|
-
def after_method(arg); end
|
124
|
-
|
125
|
-
def transition_method(arg); end
|
126
|
-
|
127
|
-
def transition_method2(arg); end
|
128
|
-
|
129
|
-
end
|