big_machine 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/big_machine/active_record.rb +6 -2
- data/lib/big_machine/version.rb +1 -1
- data/test/big_machine_test.rb +6 -1
- metadata +52 -47
@@ -16,7 +16,11 @@ module BigMachine
|
|
16
16
|
|
17
17
|
def set_current_state_from_db
|
18
18
|
attribute = send state_attribute
|
19
|
-
|
19
|
+
if attribute
|
20
|
+
set_current_state(attribute.constantize)
|
21
|
+
else
|
22
|
+
self.class.set_initial_state_class
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
def set_current_state(new_state_class)
|
@@ -29,4 +33,4 @@ module BigMachine
|
|
29
33
|
save!
|
30
34
|
end
|
31
35
|
end
|
32
|
-
end
|
36
|
+
end
|
data/lib/big_machine/version.rb
CHANGED
data/test/big_machine_test.rb
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
|
15
15
|
class LockState < BigMachine::State
|
16
16
|
include BigMachine::Lock
|
17
|
-
|
17
|
+
|
18
18
|
def back_to_draft
|
19
19
|
transition_to Draft
|
20
20
|
end
|
@@ -123,4 +123,9 @@ class BigMachineTest < ActiveSupport::TestCase
|
|
123
123
|
assert_equal 'Draft', @dummyAR.current_state.class.name
|
124
124
|
assert_equal 'Draft', @dummyAR.state
|
125
125
|
end
|
126
|
+
|
127
|
+
test "big_machine must set initial state even if active record object" do
|
128
|
+
@dummyWS = DummyWithActiveRecord.new(nil)
|
129
|
+
assert_equal 'Draft', @dummyWS.current_state.class.name
|
130
|
+
end
|
126
131
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: big_machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: 3.2.8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.8
|
25
30
|
description: Add support for creating state machine on any ruby object
|
26
31
|
email:
|
27
32
|
- anthony.laibe@gmail.com
|
@@ -29,46 +34,46 @@ executables: []
|
|
29
34
|
extensions: []
|
30
35
|
extra_rdoc_files: []
|
31
36
|
files:
|
37
|
+
- lib/big_machine.rb
|
38
|
+
- lib/big_machine/version.rb
|
32
39
|
- lib/big_machine/active_record.rb
|
33
40
|
- lib/big_machine/lock.rb
|
34
41
|
- lib/big_machine/state.rb
|
35
42
|
- lib/big_machine/transition_methods.rb
|
36
|
-
- lib/big_machine/version.rb
|
37
|
-
- lib/big_machine.rb
|
38
43
|
- lib/tasks/big_machine_tasks.rake
|
39
44
|
- MIT-LICENSE
|
40
45
|
- Rakefile
|
41
46
|
- README.md
|
42
|
-
- test/
|
43
|
-
- test/dummy/
|
44
|
-
- test/dummy/app/assets/stylesheets/application.css
|
45
|
-
- test/dummy/app/controllers/application_controller.rb
|
46
|
-
- test/dummy/app/helpers/application_helper.rb
|
47
|
-
- test/dummy/app/views/layouts/application.html.erb
|
48
|
-
- test/dummy/config/application.rb
|
49
|
-
- test/dummy/config/boot.rb
|
50
|
-
- test/dummy/config/environment.rb
|
47
|
+
- test/dummy/README.rdoc
|
48
|
+
- test/dummy/log/test.log
|
51
49
|
- test/dummy/config/environments/development.rb
|
52
50
|
- test/dummy/config/environments/production.rb
|
53
51
|
- test/dummy/config/environments/test.rb
|
54
|
-
- test/dummy/config/initializers/
|
52
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
53
|
+
- test/dummy/config/initializers/session_store.rb
|
55
54
|
- test/dummy/config/initializers/inflections.rb
|
56
|
-
- test/dummy/config/initializers/
|
55
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
57
56
|
- test/dummy/config/initializers/secret_token.rb
|
58
|
-
- test/dummy/config/initializers/
|
59
|
-
- test/dummy/config/
|
60
|
-
- test/dummy/config/
|
57
|
+
- test/dummy/config/initializers/mime_types.rb
|
58
|
+
- test/dummy/config/boot.rb
|
59
|
+
- test/dummy/config/application.rb
|
60
|
+
- test/dummy/config/environment.rb
|
61
61
|
- test/dummy/config/routes.rb
|
62
|
-
- test/dummy/config.
|
63
|
-
- test/dummy/
|
64
|
-
- test/dummy/public/404.html
|
62
|
+
- test/dummy/config/locales/en.yml
|
63
|
+
- test/dummy/Rakefile
|
65
64
|
- test/dummy/public/422.html
|
66
|
-
- test/dummy/public/500.html
|
67
65
|
- test/dummy/public/favicon.ico
|
68
|
-
- test/dummy/
|
69
|
-
- test/dummy/
|
66
|
+
- test/dummy/public/404.html
|
67
|
+
- test/dummy/public/500.html
|
68
|
+
- test/dummy/app/helpers/application_helper.rb
|
69
|
+
- test/dummy/app/controllers/application_controller.rb
|
70
|
+
- test/dummy/app/views/layouts/application.html.erb
|
71
|
+
- test/dummy/app/assets/stylesheets/application.css
|
72
|
+
- test/dummy/app/assets/javascripts/application.js
|
70
73
|
- test/dummy/script/rails
|
74
|
+
- test/dummy/config.ru
|
71
75
|
- test/test_helper.rb
|
76
|
+
- test/big_machine_test.rb
|
72
77
|
homepage: https://github.com/alaibe/big_machine
|
73
78
|
licenses: []
|
74
79
|
post_install_message:
|
@@ -89,38 +94,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
94
|
version: '0'
|
90
95
|
requirements: []
|
91
96
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.8.
|
97
|
+
rubygems_version: 1.8.23
|
93
98
|
signing_key:
|
94
99
|
specification_version: 3
|
95
100
|
summary: State machine for any ruby object
|
96
101
|
test_files:
|
97
|
-
- test/
|
98
|
-
- test/dummy/
|
99
|
-
- test/dummy/app/assets/stylesheets/application.css
|
100
|
-
- test/dummy/app/controllers/application_controller.rb
|
101
|
-
- test/dummy/app/helpers/application_helper.rb
|
102
|
-
- test/dummy/app/views/layouts/application.html.erb
|
103
|
-
- test/dummy/config/application.rb
|
104
|
-
- test/dummy/config/boot.rb
|
105
|
-
- test/dummy/config/environment.rb
|
102
|
+
- test/dummy/README.rdoc
|
103
|
+
- test/dummy/log/test.log
|
106
104
|
- test/dummy/config/environments/development.rb
|
107
105
|
- test/dummy/config/environments/production.rb
|
108
106
|
- test/dummy/config/environments/test.rb
|
109
|
-
- test/dummy/config/initializers/
|
107
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
108
|
+
- test/dummy/config/initializers/session_store.rb
|
110
109
|
- test/dummy/config/initializers/inflections.rb
|
111
|
-
- test/dummy/config/initializers/
|
110
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
112
111
|
- test/dummy/config/initializers/secret_token.rb
|
113
|
-
- test/dummy/config/initializers/
|
114
|
-
- test/dummy/config/
|
115
|
-
- test/dummy/config/
|
112
|
+
- test/dummy/config/initializers/mime_types.rb
|
113
|
+
- test/dummy/config/boot.rb
|
114
|
+
- test/dummy/config/application.rb
|
115
|
+
- test/dummy/config/environment.rb
|
116
116
|
- test/dummy/config/routes.rb
|
117
|
-
- test/dummy/config.
|
118
|
-
- test/dummy/
|
119
|
-
- test/dummy/public/404.html
|
117
|
+
- test/dummy/config/locales/en.yml
|
118
|
+
- test/dummy/Rakefile
|
120
119
|
- test/dummy/public/422.html
|
121
|
-
- test/dummy/public/500.html
|
122
120
|
- test/dummy/public/favicon.ico
|
123
|
-
- test/dummy/
|
124
|
-
- test/dummy/
|
121
|
+
- test/dummy/public/404.html
|
122
|
+
- test/dummy/public/500.html
|
123
|
+
- test/dummy/app/helpers/application_helper.rb
|
124
|
+
- test/dummy/app/controllers/application_controller.rb
|
125
|
+
- test/dummy/app/views/layouts/application.html.erb
|
126
|
+
- test/dummy/app/assets/stylesheets/application.css
|
127
|
+
- test/dummy/app/assets/javascripts/application.js
|
125
128
|
- test/dummy/script/rails
|
129
|
+
- test/dummy/config.ru
|
126
130
|
- test/test_helper.rb
|
131
|
+
- test/big_machine_test.rb
|