aasm 5.0.6 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +13 -13
- data/Appraisals +6 -10
- data/CHANGELOG.md +33 -0
- data/Gemfile +1 -1
- data/README.md +102 -13
- data/aasm.gemspec +1 -1
- data/gemfiles/norails.gemfile +1 -1
- data/gemfiles/rails_4.2.gemfile +1 -0
- data/gemfiles/rails_4.2_mongoid_5.gemfile +1 -0
- data/gemfiles/rails_5.0.gemfile +1 -0
- data/gemfiles/rails_5.1.gemfile +1 -0
- data/gemfiles/rails_5.2.gemfile +1 -0
- data/lib/aasm.rb +0 -2
- data/lib/aasm/base.rb +30 -11
- data/lib/aasm/configuration.rb +3 -0
- data/lib/aasm/core/event.rb +7 -2
- data/lib/aasm/core/state.rb +6 -5
- data/lib/aasm/core/transition.rb +1 -1
- data/lib/aasm/dsl_helper.rb +24 -22
- data/lib/aasm/instance_base.rb +12 -1
- data/lib/aasm/localizer.rb +13 -3
- data/lib/aasm/persistence/active_record_persistence.rb +18 -0
- data/lib/aasm/persistence/base.rb +13 -2
- data/lib/aasm/persistence/orm.rb +23 -19
- data/lib/aasm/rspec/transition_from.rb +5 -1
- data/lib/aasm/version.rb +1 -1
- data/spec/database.rb +10 -12
- data/spec/en.yml +0 -3
- data/spec/{en_deprecated_style.yml → localizer_test_model_deprecated_style.yml} +6 -3
- data/spec/localizer_test_model_new_style.yml +11 -0
- data/spec/models/active_record/active_record_callback.rb +93 -0
- data/spec/models/active_record/localizer_test_model.rb +11 -3
- data/spec/models/active_record/namespaced.rb +16 -0
- data/spec/models/active_record/timestamp_example.rb +16 -0
- data/spec/models/default_state.rb +1 -1
- data/spec/models/mongoid/timestamp_example_mongoid.rb +20 -0
- data/spec/models/simple_example.rb +6 -0
- data/spec/models/timestamps_example.rb +19 -0
- data/spec/models/timestamps_with_named_machine_example.rb +13 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/unit/api_spec.rb +4 -0
- data/spec/unit/inspection_multiple_spec.rb +9 -5
- data/spec/unit/inspection_spec.rb +7 -3
- data/spec/unit/localizer_spec.rb +49 -18
- data/spec/unit/persistence/active_record_persistence_multiple_spec.rb +17 -0
- data/spec/unit/persistence/active_record_persistence_spec.rb +79 -0
- data/spec/unit/persistence/mongoid_persistence_spec.rb +12 -0
- data/spec/unit/rspec_matcher_spec.rb +3 -0
- data/spec/unit/simple_example_spec.rb +15 -0
- data/spec/unit/state_spec.rb +21 -5
- data/spec/unit/timestamps_spec.rb +32 -0
- metadata +26 -13
- data/callbacks.txt +0 -51
- data/gemfiles/rails_3.2.gemfile +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e3ec7032fd9c8368ddfb4bed4e931edc5f9d96c02a69f89f7ee26913f7d8698
|
4
|
+
data.tar.gz: ddb4ef39501440da1869426eda3b4359e37eeef67b464c9e0d660e9f353510f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c294de071cad6569f855af1455c9d0281622ca5c9a3df0466baacaca569d8974718eb46d4c06e674f54629a77e2634d69829ee2910612ba146b4aaf786891544
|
7
|
+
data.tar.gz: a7b0c176cec262ad9d89538fe43e6df484f4d79328f85e853dcc9fe6b6ce9a9629f802e7de14659e5c91135a3a4df09a6066011983b1936eff06b17657c24cc5
|
data/.travis.yml
CHANGED
@@ -12,8 +12,9 @@ before_install:
|
|
12
12
|
- bundle _1.16.1_ install
|
13
13
|
|
14
14
|
rvm:
|
15
|
-
- 2.3.0
|
16
15
|
- 2.5.0
|
16
|
+
- 2.6.5
|
17
|
+
- 2.7.0
|
17
18
|
- jruby-9.1.12.0
|
18
19
|
|
19
20
|
services:
|
@@ -25,7 +26,6 @@ services:
|
|
25
26
|
|
26
27
|
gemfile:
|
27
28
|
- gemfiles/norails.gemfile
|
28
|
-
- gemfiles/rails_3.2.gemfile
|
29
29
|
- gemfiles/rails_4.2.gemfile
|
30
30
|
- gemfiles/rails_4.2_mongoid_5.gemfile
|
31
31
|
# - gemfiles/rails_4.2_nobrainer.gemfile
|
@@ -46,22 +46,22 @@ script:
|
|
46
46
|
|
47
47
|
matrix:
|
48
48
|
exclude:
|
49
|
-
- rvm: 2.
|
50
|
-
gemfile: gemfiles/
|
51
|
-
- rvm: 2.
|
52
|
-
gemfile: gemfiles/rails_5.0.gemfile
|
53
|
-
# - rvm: 2.3.0
|
54
|
-
# gemfile: gemfiles/rails_5.0_nobrainer.gemfile
|
55
|
-
- rvm: 2.3.0
|
56
|
-
gemfile: gemfiles/rails_5.1.gemfile
|
57
|
-
- rvm: 2.3.0
|
49
|
+
- rvm: 2.7.0
|
50
|
+
gemfile: gemfiles/rails_5.2.gemfile
|
51
|
+
- rvm: 2.6.5
|
58
52
|
gemfile: gemfiles/rails_5.2.gemfile
|
59
53
|
- rvm: 2.5.0
|
60
|
-
gemfile: gemfiles/
|
61
|
-
- rvm: 2.5
|
54
|
+
gemfile: gemfiles/rails_4.2.gemfile
|
55
|
+
- rvm: 2.6.5
|
56
|
+
gemfile: gemfiles/rails_4.2.gemfile
|
57
|
+
- rvm: 2.7.0
|
62
58
|
gemfile: gemfiles/rails_4.2.gemfile
|
63
59
|
- rvm: 2.5.0
|
64
60
|
gemfile: gemfiles/rails_4.2_mongoid_5.gemfile
|
61
|
+
- rvm: 2.6.5
|
62
|
+
gemfile: gemfiles/rails_4.2_mongoid_5.gemfile
|
63
|
+
- rvm: 2.7.0
|
64
|
+
gemfile: gemfiles/rails_4.2_mongoid_5.gemfile
|
65
65
|
# - rvm: 2.5.0
|
66
66
|
# gemfile: gemfiles/rails_4.2_nobrainer.gemfile
|
67
67
|
- rvm: jruby-9.1.12.0
|
data/Appraisals
CHANGED
@@ -1,13 +1,3 @@
|
|
1
|
-
appraise 'rails_3.2' do
|
2
|
-
gem 'rails', '~> 3.2.22'
|
3
|
-
gem 'mongoid', '~> 3.1'
|
4
|
-
gem 'sequel'
|
5
|
-
gem 'bson_ext', platforms: :ruby
|
6
|
-
gem 'test-unit', '~> 3.0'
|
7
|
-
gem 'minitest'
|
8
|
-
gem 'activerecord-jdbcsqlite3-adapter', '1.3.24', platforms: :jruby
|
9
|
-
end
|
10
|
-
|
11
1
|
appraise 'rails_4.2' do
|
12
2
|
gem 'nokogiri', '1.6.8.1', platforms: %i[ruby_19]
|
13
3
|
gem 'mime-types', '~> 2', platforms: %i[ruby_19 jruby]
|
@@ -18,6 +8,7 @@ appraise 'rails_4.2' do
|
|
18
8
|
gem 'aws-sdk', '~> 2', platforms: :ruby
|
19
9
|
gem 'redis-objects'
|
20
10
|
gem 'activerecord-jdbcsqlite3-adapter', '1.3.24', platforms: :jruby
|
11
|
+
gem "after_commit_everywhere", "~> 1.0"
|
21
12
|
end
|
22
13
|
|
23
14
|
appraise 'rails_4.2_nobrainer' do
|
@@ -30,6 +21,7 @@ appraise 'rails_4.2_mongoid_5' do
|
|
30
21
|
gem 'rails', '4.2.5'
|
31
22
|
gem 'mongoid', '~> 5.0'
|
32
23
|
gem 'activerecord-jdbcsqlite3-adapter', '1.3.24', platforms: :jruby
|
24
|
+
gem "after_commit_everywhere", "~> 1.0"
|
33
25
|
end
|
34
26
|
|
35
27
|
appraise 'rails_5.0' do
|
@@ -39,6 +31,7 @@ appraise 'rails_5.0' do
|
|
39
31
|
gem 'dynamoid', '~> 1.3', platforms: :ruby
|
40
32
|
gem 'aws-sdk', '~> 2', platforms: :ruby
|
41
33
|
gem 'redis-objects'
|
34
|
+
gem "after_commit_everywhere", "~> 1.0"
|
42
35
|
end
|
43
36
|
|
44
37
|
appraise 'rails_5.0_nobrainer' do
|
@@ -53,6 +46,7 @@ appraise 'rails_5.1' do
|
|
53
46
|
gem 'dynamoid', '~> 1.3', platforms: :ruby
|
54
47
|
gem 'aws-sdk', '~>2', platforms: :ruby
|
55
48
|
gem 'redis-objects'
|
49
|
+
gem "after_commit_everywhere", "~> 1.0"
|
56
50
|
end
|
57
51
|
|
58
52
|
appraise 'rails_5.2' do
|
@@ -62,9 +56,11 @@ appraise 'rails_5.2' do
|
|
62
56
|
gem 'dynamoid', '~>2.2', platforms: :ruby
|
63
57
|
gem 'aws-sdk', '~>2', platforms: :ruby
|
64
58
|
gem 'redis-objects'
|
59
|
+
gem "after_commit_everywhere", "~> 1.0"
|
65
60
|
end
|
66
61
|
|
67
62
|
appraise 'norails' do
|
63
|
+
gem 'sqlite3', '~> 1.3', '>= 1.3.5', platforms: :ruby
|
68
64
|
gem 'rails', install_if: false
|
69
65
|
gem 'sequel'
|
70
66
|
gem 'redis-objects'
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,39 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
3
|
## unreleased
|
4
|
+
## 5.2.0
|
5
|
+
|
6
|
+
* fix: timestamp will work with named machine [#739](https://github.com/aasm/aasm/pull/739), thanks to [RolandStuder](https://github.com/RolandStuder)
|
7
|
+
* Create namespaced scopes in PR [#735](https://github.com/aasm/aasm/pull/735), thanks to [caiohsramos](https://github.com/caiohsramos)
|
8
|
+
* Fix multiple state machines example per class on README in PR [#732](https://github.com/aasm/aasm/pull/732), thanks to [RodrigoVitiello](https://github.com/RodrigoVitiello)
|
9
|
+
* Update version in recommendation to add after_commit_everywhere in PR [#729](https://github.com/aasm/aasm/pull/729), thanks to [Envek](https://github.com/Envek)
|
10
|
+
* Fix i18n Event translations failing [#721](https://github.com/aasm/aasm/issues/721) in PR [#723](https://github.com/aasm/aasm/pull/723), thanks to [the-spectator](https://github.com/the-spectator)
|
11
|
+
* Add documentation to the Readme about how parameters are handled in AASM events in PR [#722](https://github.com/aasm/aasm/pull/722), thanks to [dstuebe](https://github.com/dstuebe)
|
12
|
+
* Fix human_state cached across locales [#709](https://github.com/aasm/aasm/issues/709) in PR [716](https://github.com/aasm/aasm/pull/716), thanks to [the-spectator](https://github.com/the-spectator)
|
13
|
+
* Relocate DslHelper from root namespace to under AASM namespace in PR [#711](https://github.com/aasm/aasm/pull/711) thank to [yujideveloper ](https://github.com/yujideveloper )
|
14
|
+
* Document how to define transitions from any state in in PR [#699](https://github.com/aasm/aasm/pull/699) thanks to [hedgesky](https://github.com/hedgesky)
|
15
|
+
* Add simple option for auto-generated timestamps in PR [#677](https://github.com/aasm/aasm/pull/677), thanks to [jaynetics](https://github.com/jaynetics)
|
16
|
+
## 5.1.1
|
17
|
+
|
18
|
+
* Fix Depreciation message for after_commit_everywhere [#695](https://github.com/aasm/aasm/issues/695) in PR [#696](https://github.com/aasm/aasm/pull/696)
|
19
|
+
* Fix human_state to use display option [#684](https://github.com/aasm/aasm/issues/684) in PR [#697](https://github.com/aasm/aasm/pull/697)
|
20
|
+
* Remove support for ruby 2.3
|
21
|
+
|
22
|
+
## 5.1.0
|
23
|
+
|
24
|
+
* Fix after_commit in nested transactions [#536](https://github.com/aasm/aasm/issues/536) without explicit AR dependency in PR [#668](https://github.com/aasm/aasm/pull/668), thanks to [stokarenko](https://github.com/stokarenko)
|
25
|
+
* Remove support for Rails 3.2
|
26
|
+
|
27
|
+
## 5.0.8
|
28
|
+
|
29
|
+
* Revert Fix for :after_commit within nested transaction because it adds after_commit_action dependency which is dependent on many gems.
|
30
|
+
|
31
|
+
## 5.0.7
|
32
|
+
|
33
|
+
* Fix :after_commit within nested transaction [#666](https://github.com/aasm/aasm/pull/666), thanks to [stokarenko](https://github.com/stokarenko)
|
34
|
+
* Add permitted_transitions to group permitted event with state [#664](https://github.com/aasm/aasm/pull/664), thanks to [dnamsons](https://github.com/dnamsons)
|
35
|
+
* Add Ruby 2.7.0 & 2.6.5 to Travis CI Test Matrix [#661](https://github.com/aasm/aasm/pull/661), thanks to [the-spectator](https://github.com/the-spectator)
|
36
|
+
* Handle InvalidTransition in transition_from matcher [#653](https://github.com/aasm/aasm/pull/653), thanks to [ryanwood](https://github.com/ryanwood)
|
4
37
|
|
5
38
|
## 5.0.6
|
6
39
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -20,6 +20,7 @@
|
|
20
20
|
- [Extending AASM](#extending-aasm)
|
21
21
|
- [ActiveRecord](#activerecord)
|
22
22
|
- [Bang events](#bang-events)
|
23
|
+
- [Timestamps](#timestamps)
|
23
24
|
- [ActiveRecord enums](#activerecord-enums)
|
24
25
|
- [Sequel](#sequel)
|
25
26
|
- [Dynamoid](#dynamoid)
|
@@ -212,15 +213,28 @@ class LogRunTime
|
|
212
213
|
end
|
213
214
|
```
|
214
215
|
|
215
|
-
|
216
|
+
#### Parameters
|
217
|
+
You can pass parameters to events:
|
216
218
|
|
217
219
|
```ruby
|
218
220
|
job = Job.new
|
219
221
|
job.run(:defragmentation)
|
220
222
|
```
|
221
223
|
|
222
|
-
In this case
|
224
|
+
All guards and after callbacks will receive these parameters. In this case `set_process` would be called with
|
225
|
+
`:defragmentation` argument.
|
223
226
|
|
227
|
+
If the first argument to the event is a state (e.g. `:running` or `:finished`), the first argument is consumed and
|
228
|
+
the state machine will attempt to transition to that state. Add comma separated parameter for gaurds and callbacks
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
job = Job.new
|
232
|
+
job.run(:running, :defragmentation)
|
233
|
+
```
|
234
|
+
In this case `set_process` won't be called, job will transition to running state and callback will receive
|
235
|
+
:defragmentation as parameter
|
236
|
+
|
237
|
+
#### Error Handling
|
224
238
|
In case of an error during the event processing the error is rescued and passed to `:error`
|
225
239
|
callback, which can handle it or re-raise it for further propagation.
|
226
240
|
|
@@ -260,8 +274,8 @@ begin
|
|
260
274
|
new_state enter
|
261
275
|
...update state...
|
262
276
|
event before_success # if persist successful
|
263
|
-
transition success # if persist successful
|
264
|
-
event success # if persist successful
|
277
|
+
transition success # if persist successful, database update not guaranteed
|
278
|
+
event success # if persist successful, database update not guaranteed
|
265
279
|
old_state after_exit
|
266
280
|
new_state after_enter
|
267
281
|
event after
|
@@ -275,6 +289,8 @@ ensure
|
|
275
289
|
end
|
276
290
|
```
|
277
291
|
|
292
|
+
Use event's `after_commit` callback if it should be fired after database update.
|
293
|
+
|
278
294
|
#### The current event triggered
|
279
295
|
|
280
296
|
While running the callbacks you can easily retrieve the name of the event triggered
|
@@ -432,16 +448,43 @@ job.stage1_completed
|
|
432
448
|
job.aasm.current_state # stage3
|
433
449
|
```
|
434
450
|
|
451
|
+
You can define transition from any defined state by omitting `from`:
|
452
|
+
|
453
|
+
```ruby
|
454
|
+
event :abort do
|
455
|
+
transitions to: :aborted
|
456
|
+
end
|
457
|
+
```
|
458
|
+
|
459
|
+
### Display name for state
|
460
|
+
|
461
|
+
You can define display name for state using :display option
|
462
|
+
|
463
|
+
```ruby
|
464
|
+
class Job
|
465
|
+
include AASM
|
466
|
+
|
467
|
+
aasm do
|
468
|
+
state :stage1, initial: true, display: 'First Stage'
|
469
|
+
state :stage2
|
470
|
+
state :stage3
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
474
|
+
job = Job.new
|
475
|
+
job.aasm.human_state
|
476
|
+
|
477
|
+
```
|
435
478
|
|
436
479
|
### Multiple state machines per class
|
437
480
|
|
438
481
|
Multiple state machines per class are supported. Be aware though that _AASM_ has been
|
439
|
-
built with one state machine per class in mind. Nonetheless, here's how to do it
|
482
|
+
built with one state machine per class in mind. Nonetheless, here's how to do it (see below). Please note that you will need to specify database columns for where your pertinent states will be stored - we have specified two columns `move_state` and `work_state` in the example below. See the [Column name & migration](https://github.com/aasm/aasm#column-name--migration) section for further info.
|
440
483
|
|
441
484
|
```ruby
|
442
485
|
class SimpleMultipleExample
|
443
486
|
include AASM
|
444
|
-
aasm(:move) do
|
487
|
+
aasm(:move, column: 'move_state') do
|
445
488
|
state :standing, initial: true
|
446
489
|
state :walking
|
447
490
|
state :running
|
@@ -457,7 +500,7 @@ class SimpleMultipleExample
|
|
457
500
|
end
|
458
501
|
end
|
459
502
|
|
460
|
-
aasm(:work) do
|
503
|
+
aasm(:work, column: 'work_state') do
|
461
504
|
state :sleeping, initial: true
|
462
505
|
state :processing
|
463
506
|
|
@@ -474,13 +517,13 @@ simple = SimpleMultipleExample.new
|
|
474
517
|
|
475
518
|
simple.aasm(:move).current_state
|
476
519
|
# => :standing
|
477
|
-
simple.aasm(:work).
|
520
|
+
simple.aasm(:work).current_state
|
478
521
|
# => :sleeping
|
479
522
|
|
480
523
|
simple.start
|
481
524
|
simple.aasm(:move).current_state
|
482
525
|
# => :standing
|
483
|
-
simple.aasm(:work).
|
526
|
+
simple.aasm(:work).current_state
|
484
527
|
# => :processing
|
485
528
|
|
486
529
|
```
|
@@ -677,6 +720,8 @@ end
|
|
677
720
|
AASM comes with support for ActiveRecord and allows automatic persisting of the object's
|
678
721
|
state in the database.
|
679
722
|
|
723
|
+
Add `gem 'after_commit_everywhere', '~> 1.0'` to your Gemfile.
|
724
|
+
|
680
725
|
```ruby
|
681
726
|
class Job < ActiveRecord::Base
|
682
727
|
include AASM
|
@@ -777,6 +822,37 @@ job.aasm_state = :running # => raises AASM::NoDirectAssignmentError
|
|
777
822
|
job.aasm_state # => 'sleeping'
|
778
823
|
```
|
779
824
|
|
825
|
+
### Timestamps
|
826
|
+
|
827
|
+
You can tell _AASM_ to try to write a timestamp whenever a new state is entered.
|
828
|
+
If `timestamps: true` is set, _AASM_ will look for a field named like the new state plus `_at` and try to fill it:
|
829
|
+
|
830
|
+
```ruby
|
831
|
+
class Job < ActiveRecord::Base
|
832
|
+
include AASM
|
833
|
+
|
834
|
+
aasm timestamps: true do
|
835
|
+
state :sleeping, initial: true
|
836
|
+
state :running
|
837
|
+
|
838
|
+
event :run do
|
839
|
+
transitions from: :sleeping, to: :running
|
840
|
+
end
|
841
|
+
end
|
842
|
+
end
|
843
|
+
```
|
844
|
+
|
845
|
+
resulting in this:
|
846
|
+
|
847
|
+
```ruby
|
848
|
+
job = Job.create
|
849
|
+
job.running_at # => nil
|
850
|
+
job.run!
|
851
|
+
job.running_at # => 2020-02-20 20:00:00
|
852
|
+
```
|
853
|
+
|
854
|
+
Missing timestamp fields are silently ignored, so it is not necessary to have setters (such as ActiveRecord columns) for *all* states when using this option.
|
855
|
+
|
780
856
|
#### ActiveRecord enums
|
781
857
|
|
782
858
|
You can use
|
@@ -981,6 +1057,12 @@ job.run
|
|
981
1057
|
job.save! #notify_about_running_job is not run
|
982
1058
|
```
|
983
1059
|
|
1060
|
+
Please note that `:after_commit` AASM callbacks behaves around custom implementation
|
1061
|
+
of transaction pattern rather than a real-life DB transaction. This fact still causes
|
1062
|
+
the race conditions and redundant callback calls within nested transaction. In order
|
1063
|
+
to fix that it's highly recommended to add `gem 'after_commit_everywhere', '~> 1.0'`
|
1064
|
+
to your `Gemfile`.
|
1065
|
+
|
984
1066
|
If you want to encapsulate state changes within an own transaction, the behavior
|
985
1067
|
of this nested transaction might be confusing. Take a look at
|
986
1068
|
[ActiveRecord Nested Transactions](http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html)
|
@@ -1065,18 +1147,21 @@ this by defining your favorite column name, using `:column` like this:
|
|
1065
1147
|
class Job < ActiveRecord::Base
|
1066
1148
|
include AASM
|
1067
1149
|
|
1068
|
-
aasm column:
|
1150
|
+
aasm column: :my_state do
|
1069
1151
|
...
|
1070
1152
|
end
|
1071
1153
|
|
1072
|
-
aasm :another_state_machine, column:
|
1154
|
+
aasm :another_state_machine, column: :second_state do
|
1073
1155
|
...
|
1074
1156
|
end
|
1075
1157
|
end
|
1076
1158
|
```
|
1077
1159
|
|
1078
1160
|
Whatever column name is used, make sure to add a migration to provide this column
|
1079
|
-
(of type `string`)
|
1161
|
+
(of type `string`).
|
1162
|
+
Do not add default value for column at the database level. If you add default
|
1163
|
+
value in database then AASM callbacks on the initial state will not be fired upon
|
1164
|
+
instantiation of the model.
|
1080
1165
|
|
1081
1166
|
```ruby
|
1082
1167
|
class AddJobState < ActiveRecord::Migration
|
@@ -1092,7 +1177,7 @@ end
|
|
1092
1177
|
|
1093
1178
|
### Log State Changes
|
1094
1179
|
|
1095
|
-
Logging state change can be done using [paper_trail](https://github.com/paper-trail-gem/paper_trail) gem
|
1180
|
+
Logging state change can be done using [paper_trail](https://github.com/paper-trail-gem/paper_trail) gem
|
1096
1181
|
|
1097
1182
|
Example of implementation can be found here [https://github.com/nitsujri/aasm-papertrail-example](https://github.com/nitsujri/aasm-papertrail-example)
|
1098
1183
|
|
@@ -1141,6 +1226,10 @@ job = Job.new
|
|
1141
1226
|
job.aasm.states(permitted: true).map(&:name)
|
1142
1227
|
#=> [:running]
|
1143
1228
|
|
1229
|
+
# List all the permitted transitions(event and state pairs) from initial state
|
1230
|
+
job.aasm.permitted_transitions
|
1231
|
+
#=> [{ :event => :run, :state => :running }]
|
1232
|
+
|
1144
1233
|
job.run
|
1145
1234
|
job.aasm.states(permitted: true).map(&:name)
|
1146
1235
|
#=> [:sleeping]
|
data/aasm.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_development_dependency 'generator_spec'
|
25
25
|
s.add_development_dependency 'appraisal'
|
26
26
|
s.add_development_dependency "simplecov"
|
27
|
-
s.add_development_dependency "codecov", ">= 0.1.
|
27
|
+
s.add_development_dependency "codecov", ">= 0.1.21"
|
28
28
|
|
29
29
|
# debugging
|
30
30
|
# s.add_development_dependency 'debugger'
|
data/gemfiles/norails.gemfile
CHANGED
data/gemfiles/rails_4.2.gemfile
CHANGED
data/gemfiles/rails_5.0.gemfile
CHANGED