statesman-multi_state 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b9099221442802c1cfdde02ba1a21000c6f02f6f16e962f7128e444424e6b0aa
|
|
4
|
+
data.tar.gz: a93e7228b987832c6353a78d7874643046858222cdf45982a15aeac54ee9c917
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8afb9f921c1c5a9f40876d7aafc7f1bf98dea36d129b8d1a9e2a9f58094e79b649896439c8a65e6cc3fe649a83a7f31344638be7bfcb76d7f0a71e13ea4ad959
|
|
7
|
+
data.tar.gz: 1688224fb72dd2d96cbc77975d43b101f9b5a1043ff28b19930948e15bf3c3756ce4696318b251bef3f3d6ab846a32851cd99edc1fa2dd3a0135681aa0eec94b
|
|
@@ -41,16 +41,22 @@ module Statesman
|
|
|
41
41
|
key = "@#{state_machine_name}"
|
|
42
42
|
return instance_variable_get(key) if instance_variable_defined?(key) && @#{state_machine_name}.object.persisted?
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
state_machine = #{state_machine_klass}.new(
|
|
45
45
|
self,
|
|
46
46
|
transition_class: #{transition_klass},
|
|
47
47
|
association_name: "#{transition_name}",
|
|
48
48
|
initial_transition: false
|
|
49
|
-
)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Not persisted yet: the initial transition below cannot be written. Do not memoize this
|
|
52
|
+
# machine, otherwise the first read after the INSERT would return it and skip that transition.
|
|
53
|
+
return state_machine unless persisted?
|
|
54
|
+
|
|
55
|
+
instance_variable_set(key, state_machine)
|
|
50
56
|
|
|
51
57
|
if #{initial_transition}
|
|
52
58
|
if @#{state_machine_name}.history.empty? && #{state_machine_klass}.initial_state
|
|
53
|
-
if
|
|
59
|
+
if self.class.current_role != ::ActiveRecord.reading_role
|
|
54
60
|
@#{state_machine_name}.instance_variable_get(:@storage_adapter).create(nil, #{state_machine_klass}.initial_state)
|
|
55
61
|
end
|
|
56
62
|
end
|