nxt_state_machine 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +9 -6
- data/lib/nxt_state_machine/version.rb +1 -1
- data/nxt_state_machine.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77b32ce5c0f8c968180650e6497e84076803948c832e84d5c63145ff10050c46
|
4
|
+
data.tar.gz: 5a5f210aaf9b8f0d8278a66851f4d3be8f278a4a448975252610b3eebe292b06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbbf6e38dc538a6e5018d9839c591ddf707cc5d348c310582680e8cf588715545214ebe1b16ab70dddad63a0cfa97ab7d66121752ffc1034813128fdb0f2e1e7
|
7
|
+
data.tar.gz: ef95346d040eb48905820314241e67009d846c00c71725cc2ab24948db0e426d7cdddb1fd55c01d7e63a15d465d0342adf9d35f888d6c62d1d21ba596f19bd54
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nxt_state_machine (0.1.
|
4
|
+
nxt_state_machine (0.1.6)
|
5
5
|
activesupport
|
6
6
|
nxt_registry (~> 0.1.3)
|
7
7
|
|
@@ -31,7 +31,7 @@ GEM
|
|
31
31
|
pry (0.12.2)
|
32
32
|
coderay (~> 1.1.0)
|
33
33
|
method_source (~> 0.9.0)
|
34
|
-
rake (
|
34
|
+
rake (12.3.3)
|
35
35
|
rspec (3.9.0)
|
36
36
|
rspec-core (~> 3.9.0)
|
37
37
|
rspec-expectations (~> 3.9.0)
|
@@ -61,7 +61,7 @@ DEPENDENCIES
|
|
61
61
|
bundler (~> 2.0)
|
62
62
|
nxt_state_machine!
|
63
63
|
pry
|
64
|
-
rake (~>
|
64
|
+
rake (~> 12.0)
|
65
65
|
rspec (~> 3.0)
|
66
66
|
rspec_junit_formatter
|
67
67
|
sqlite3
|
data/README.md
CHANGED
@@ -335,8 +335,6 @@ You can raise an error, have everything rolled back and then have your error han
|
|
335
335
|
error handler. You can also defuse errors. This means they will not cause a rollback of the transaction during the
|
336
336
|
transition and you can actually persist changes to your model before the defused error is raised and handled.
|
337
337
|
|
338
|
-
### Multiple state machines in the same class
|
339
|
-
|
340
338
|
```ruby
|
341
339
|
state_machine do
|
342
340
|
# ...
|
@@ -344,6 +342,9 @@ state_machine do
|
|
344
342
|
defuse CustomError, from: any_state, to: all_states
|
345
343
|
|
346
344
|
event :approve do
|
345
|
+
# You can also defuse on event level
|
346
|
+
# defuse CustomError, from: %i[written submitted deleted], to: :approved
|
347
|
+
|
347
348
|
transition from: %i[written submitted deleted], to: :approved do |headline:|
|
348
349
|
# This will be save to the database even if defused CustomError is raised after
|
349
350
|
article.update!(headline: headline)
|
@@ -353,6 +354,12 @@ state_machine do
|
|
353
354
|
|
354
355
|
on_error! CustomError from: any_state, to: :approved do |error, transition|
|
355
356
|
# You can still handle the defused Error if you want to
|
357
|
+
# You should probably reload your model here to not accidentally save changes that
|
358
|
+
# were made to the model during the transition before a non defused error was raised
|
359
|
+
article.reload
|
360
|
+
# The error callback does not run inside the transaction. No more strings attached here.
|
361
|
+
# You can now persist changes to your model again.
|
362
|
+
article.update!(error: error.message)
|
356
363
|
end
|
357
364
|
end
|
358
365
|
```
|
@@ -379,11 +386,7 @@ end
|
|
379
386
|
|
380
387
|
|
381
388
|
## TODO
|
382
|
-
- Test implementations for Hash, AttrAccessor
|
383
389
|
- Decide on how to include state methods in model classes
|
384
|
-
- Thread safety spec!
|
385
|
-
- Spec locks?
|
386
|
-
- Explain locking in readme!
|
387
390
|
- Should we clone machines for each context?
|
388
391
|
- What about inheritance? => What would be the expected behaviour? (dup vs. no dup)
|
389
392
|
=> Might also make sense to walk the ancestors chain and collect configure blocks
|
data/nxt_state_machine.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_dependency "nxt_registry", "~> 0.1.3"
|
39
39
|
|
40
40
|
spec.add_development_dependency "bundler", "~> 2.0"
|
41
|
-
spec.add_development_dependency "rake", "~>
|
41
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
42
42
|
spec.add_development_dependency "rspec", "~> 3.0"
|
43
43
|
spec.add_development_dependency "pry"
|
44
44
|
spec.add_development_dependency "activerecord"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nxt_state_machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Robecke
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2020-02
|
14
|
+
date: 2020-03-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -61,14 +61,14 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - "~>"
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: '
|
64
|
+
version: '12.0'
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - "~>"
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: '
|
71
|
+
version: '12.0'
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: rspec
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|