aasm 3.0.10 → 3.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.0.11
4
+
5
+ * added class method aasm_from_states_for_state to retrieve all from states (regarding transitions) for a given state
6
+
3
7
  ## 3.0.10
4
8
 
5
9
  * added support for transitions from all other states (thanks to Stefan 'swrobel' Wrobel)
data/lib/aasm/aasm.rb CHANGED
@@ -31,6 +31,10 @@ 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
36
+ end
37
+
34
38
  # deprecated
35
39
  def aasm_initial_state=(state)
36
40
  AASM::StateMachine[self].initial_state = state
@@ -28,6 +28,10 @@ module AASM
28
28
  @transitions.select { |t| t.from == state }
29
29
  end
30
30
 
31
+ def transitions_to_state(state)
32
+ @transitions.select { |t| t.to == state }
33
+ end
34
+
31
35
  def all_transitions
32
36
  @transitions
33
37
  end
data/lib/aasm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module AASM
2
- VERSION = "3.0.10"
2
+ VERSION = "3.0.11"
3
3
  end
@@ -1,30 +1,15 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
2
 
3
3
  describe AASM, '- class level definitions' do
4
- it 'should define a class level aasm_initial_state() method on its including class' do
4
+ it 'should define a class level methods on its including class' do
5
5
  Foo.should respond_to(:aasm_initial_state)
6
- end
7
-
8
- it 'should define a class level aasm_state() method on its including class' do
9
6
  Foo.should respond_to(:aasm_state)
10
- end
11
-
12
- it 'should define a class level aasm_event() method on its including class' do
13
7
  Foo.should respond_to(:aasm_event)
14
- end
15
-
16
- it 'should define a class level aasm_states() method on its including class' do
17
8
  Foo.should respond_to(:aasm_states)
18
- end
19
-
20
- it 'should define a class level aasm_states_for_select() method on its including class' do
21
9
  Foo.should respond_to(:aasm_states_for_select)
22
- end
23
-
24
- it 'should define a class level aasm_events() method on its including class' do
25
10
  Foo.should respond_to(:aasm_events)
11
+ Foo.should respond_to(:aasm_from_states_for_state)
26
12
  end
27
-
28
13
  end
29
14
 
30
15
  describe "naming" do
@@ -61,6 +46,13 @@ describe AASM, '- aasm_states_for_select' do
61
46
  end
62
47
  end
63
48
 
49
+ describe "aasm_from_states_for_state" do
50
+ it "should return all from states for a state" do
51
+ froms = AuthMachine.aasm_from_states_for_state(:active)
52
+ [:pending, :passive, :suspended].each {|from| froms.should include(:pending)}
53
+ end
54
+ end
55
+
64
56
  describe AASM, '- instance level definitions' do
65
57
  before(:each) do
66
58
  @foo = Foo.new
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.10
4
+ version: 3.0.11
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: &70142949460520 !ruby/object:Gem::Requirement
19
+ requirement: &70177242128740 !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: *70142949460520
27
+ version_requirements: *70177242128740
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
- requirement: &70142949460100 !ruby/object:Gem::Requirement
30
+ requirement: &70177242128320 !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: *70142949460100
38
+ version_requirements: *70177242128320
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: sdoc
41
- requirement: &70142949459680 !ruby/object:Gem::Requirement
41
+ requirement: &70177242127900 !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: *70142949459680
49
+ version_requirements: *70177242127900
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspec
52
- requirement: &70142949459180 !ruby/object:Gem::Requirement
52
+ requirement: &70177242127400 !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: *70142949459180
60
+ version_requirements: *70177242127400
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rr
63
- requirement: &70142949458760 !ruby/object:Gem::Requirement
63
+ requirement: &70177242126980 !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: *70142949458760
71
+ version_requirements: *70177242126980
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: shoulda
74
- requirement: &70142949489760 !ruby/object:Gem::Requirement
74
+ requirement: &70177242126520 !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: *70142949489760
82
+ version_requirements: *70177242126520
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sqlite3
85
- requirement: &70142949489340 !ruby/object:Gem::Requirement
85
+ requirement: &70177242126100 !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: *70142949489340
93
+ version_requirements: *70177242126100
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: minitest
96
- requirement: &70142949488920 !ruby/object:Gem::Requirement
96
+ requirement: &70177242125680 !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: *70142949488920
104
+ version_requirements: *70177242125680
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: ruby-debug-completion
107
- requirement: &70142949488500 !ruby/object:Gem::Requirement
107
+ requirement: &70177242156720 !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: *70142949488500
115
+ version_requirements: *70177242156720
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