dunedain289-aasm 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +9 -6
- data/lib/aasm.rb +3 -1
- data/lib/event.rb +9 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -17,18 +17,21 @@ The only changes I've made are creating more callbacks with slightly more obviou
|
|
17
17
|
|
18
18
|
The callback chain & order on a successful event looks like:
|
19
19
|
|
20
|
-
oldstate:exit
|
21
|
-
|
22
|
-
|
20
|
+
oldstate:exit*
|
21
|
+
event:before
|
22
|
+
__find transition, if possible__
|
23
|
+
transition:on_transition*
|
24
|
+
newstate:enter*
|
23
25
|
oldstate:before_exit
|
24
26
|
newstate:before_enter
|
25
|
-
event:before
|
26
27
|
__update state__
|
27
28
|
oldstate:after_exit
|
28
29
|
oldstate:after_enter
|
29
30
|
event:after
|
30
|
-
event:success
|
31
|
-
obj:aasm_event_fired
|
31
|
+
event:success*
|
32
|
+
obj:aasm_event_fired*
|
33
|
+
|
34
|
+
(*) marks old callbacks
|
32
35
|
|
33
36
|
Note that the old callbacks haven't been removed and still have their same semantics. All of this behavior was added without removing any old behavior.
|
34
37
|
|
data/lib/aasm.rb
CHANGED
@@ -131,6 +131,9 @@ module AASM
|
|
131
131
|
|
132
132
|
old_state.call_action(:exit, self)
|
133
133
|
|
134
|
+
# new event before callback
|
135
|
+
event.call_action(:before, self)
|
136
|
+
|
134
137
|
new_state_name = event.fire(self, *args)
|
135
138
|
|
136
139
|
unless new_state_name.nil?
|
@@ -139,7 +142,6 @@ module AASM
|
|
139
142
|
# new before_ callbacks
|
140
143
|
old_state.call_action(:before_exit, self)
|
141
144
|
new_state.call_action(:before_enter, self)
|
142
|
-
event.call_action(:before, self)
|
143
145
|
|
144
146
|
new_state.call_action(:enter, self)
|
145
147
|
|
data/lib/event.rb
CHANGED
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'state_transition')
|
|
3
3
|
module AASM
|
4
4
|
module SupportingClasses
|
5
5
|
class Event
|
6
|
-
attr_reader :name, :success
|
6
|
+
attr_reader :name, :success, :options
|
7
7
|
|
8
8
|
def initialize(name, options = {}, &block)
|
9
9
|
@name = name
|
@@ -32,6 +32,10 @@ module AASM
|
|
32
32
|
def transitions_from_state?(state)
|
33
33
|
@transitions.any? { |t| t.from == state }
|
34
34
|
end
|
35
|
+
|
36
|
+
def transitions_from_state(state)
|
37
|
+
@transitions.select { |t| t.from == state }
|
38
|
+
end
|
35
39
|
|
36
40
|
def execute_success_callback(obj)
|
37
41
|
case success
|
@@ -56,6 +60,10 @@ module AASM
|
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
63
|
+
def all_transitions
|
64
|
+
@transitions
|
65
|
+
end
|
66
|
+
|
59
67
|
private
|
60
68
|
def transitions(trans_opts)
|
61
69
|
Array(trans_opts[:from]).each do |s|
|