aasm 3.0.11 → 3.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.0.12
4
+
5
+ * aasm_from_states_for_state now supports to filter for specific transition
6
+
3
7
  ## 3.0.11
4
8
 
5
9
  * added class method aasm_from_states_for_state to retrieve all from states (regarding transitions) for a given state
@@ -31,8 +31,12 @@ module AASM
31
31
  end
32
32
  end
33
33
 
34
- def aasm_from_states_for_state(state)
35
- aasm.events.map {|k,v| v.transitions_to_state(state)}.flatten.map(&:from).flatten
34
+ def aasm_from_states_for_state(state, options={})
35
+ if options[:transition]
36
+ aasm.events[options[:transition]].transitions_to_state(state).flatten.map(&:from).flatten
37
+ else
38
+ aasm.events.map {|k,v| v.transitions_to_state(state)}.flatten.map(&:from).flatten
39
+ end
36
40
  end
37
41
 
38
42
  # deprecated
@@ -1,3 +1,3 @@
1
1
  module AASM
2
- VERSION = "3.0.11"
2
+ VERSION = "3.0.12"
3
3
  end
@@ -109,7 +109,7 @@ class AuthMachine
109
109
  event :unpassify do
110
110
  transitions :from => :passive, :to => :active, :guard => Proc.new {|u| false }
111
111
  end
112
-
112
+
113
113
  event :unsuspend do
114
114
  transitions :from => :suspended, :to => :active, :guard => Proc.new {|u| u.has_activated? }
115
115
  transitions :from => :suspended, :to => :pending, :guard => Proc.new {|u| u.has_activation_code? }
@@ -49,7 +49,12 @@ end
49
49
  describe "aasm_from_states_for_state" do
50
50
  it "should return all from states for a state" do
51
51
  froms = AuthMachine.aasm_from_states_for_state(:active)
52
- [:pending, :passive, :suspended].each {|from| froms.should include(:pending)}
52
+ [:pending, :passive, :suspended].each {|from| froms.should include(from)}
53
+ end
54
+
55
+ it "should return from states for a state for a particular transition only" do
56
+ froms = AuthMachine.aasm_from_states_for_state(:active, :transition => :unsuspend)
57
+ [:suspended].each {|from| froms.should include(from)}
53
58
  end
54
59
  end
55
60
 
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: 3.0.11
4
+ version: 3.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,7 +16,7 @@ date: 2012-10-19 00:00:00.000000000Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord
19
- requirement: &70177242128740 !ruby/object:Gem::Requirement
19
+ requirement: &70194149278160 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '0'
25
25
  type: :development
26
26
  prerelease: false
27
- version_requirements: *70177242128740
27
+ version_requirements: *70194149278160
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
- requirement: &70177242128320 !ruby/object:Gem::Requirement
30
+ requirement: &70194149277740 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: '0'
36
36
  type: :development
37
37
  prerelease: false
38
- version_requirements: *70177242128320
38
+ version_requirements: *70194149277740
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: sdoc
41
- requirement: &70177242127900 !ruby/object:Gem::Requirement
41
+ requirement: &70194149277320 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>='
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: '0'
47
47
  type: :development
48
48
  prerelease: false
49
- version_requirements: *70177242127900
49
+ version_requirements: *70194149277320
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspec
52
- requirement: &70177242127400 !ruby/object:Gem::Requirement
52
+ requirement: &70194149276820 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ~>
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: '2.0'
58
58
  type: :development
59
59
  prerelease: false
60
- version_requirements: *70177242127400
60
+ version_requirements: *70194149276820
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rr
63
- requirement: &70177242126980 !ruby/object:Gem::Requirement
63
+ requirement: &70194149276400 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ! '>='
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: '0'
69
69
  type: :development
70
70
  prerelease: false
71
- version_requirements: *70177242126980
71
+ version_requirements: *70194149276400
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: shoulda
74
- requirement: &70177242126520 !ruby/object:Gem::Requirement
74
+ requirement: &70194149275940 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ! '>='
@@ -79,10 +79,10 @@ dependencies:
79
79
  version: '0'
80
80
  type: :development
81
81
  prerelease: false
82
- version_requirements: *70177242126520
82
+ version_requirements: *70194149275940
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sqlite3
85
- requirement: &70177242126100 !ruby/object:Gem::Requirement
85
+ requirement: &70194149275520 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ! '>='
@@ -90,10 +90,10 @@ dependencies:
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
- version_requirements: *70177242126100
93
+ version_requirements: *70194149275520
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: minitest
96
- requirement: &70177242125680 !ruby/object:Gem::Requirement
96
+ requirement: &70194149275100 !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
99
  - - ! '>='
@@ -101,10 +101,10 @@ dependencies:
101
101
  version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
- version_requirements: *70177242125680
104
+ version_requirements: *70194149275100
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: ruby-debug-completion
107
- requirement: &70177242156720 !ruby/object:Gem::Requirement
107
+ requirement: &70194149306160 !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
110
110
  - - ! '>='
@@ -112,7 +112,7 @@ dependencies:
112
112
  version: '0'
113
113
  type: :development
114
114
  prerelease: false
115
- version_requirements: *70177242156720
115
+ version_requirements: *70194149306160
116
116
  description: AASM is a continuation of the acts as state machine rails plugin, built
117
117
  for plain Ruby objects.
118
118
  email: scott@elitists.net, ttilley@gmail.com, aasm@mt7.de