statesman-multi_state 0.2.6 → 0.2.7
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: 1bf730dc6e8c627150dccbc9d71deccb850c5d38b1df57571d8a9498bcc7ec3e
|
|
4
|
+
data.tar.gz: 7d2ee716b2e833fdce24a1cc0a1f18eeb1414fcdedc11a39bdebcce0af38965b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b774428fbe41859c4794c625e2adf80a0954285c376ade1cb71c2a4045cb4796fb0c9a145118c01c0d8ae6e0b3c13b1eb4744ab5dd3fe7f704588a4cc96be7c0
|
|
7
|
+
data.tar.gz: 822b889f5a7cfdde93d2602d83113588daf419bc070ab6582bf900b6fa67272e2bb9df263f6db614438b2cab136753625ca0f7e17595a8b5c931bbe911210047
|
|
@@ -64,6 +64,12 @@ module Statesman
|
|
|
64
64
|
Hash[self.class.#{field_name}_human_wrapper]
|
|
65
65
|
.invert[#{field_name}_current_state]
|
|
66
66
|
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def #{field_name}
|
|
71
|
+
#{field_name}_current_state
|
|
72
|
+
end
|
|
67
73
|
CODE
|
|
68
74
|
|
|
69
75
|
include(const_set("#{field_name}#{SecureRandom.hex(4)}_mod".classify, Module.new).tap do |mod|
|
|
@@ -84,8 +90,13 @@ module Statesman
|
|
|
84
90
|
class_eval <<~METHOD, __FILE__, __LINE__ + 1
|
|
85
91
|
def save_with_state(**options)
|
|
86
92
|
@registered_callbacks ||= []
|
|
87
|
-
if #{virtual_attribute_name}
|
|
88
|
-
|
|
93
|
+
if #{virtual_attribute_name}.to_s != #{field_name}_current_state.to_s
|
|
94
|
+
if #{field_name}_can_transition_to?(#{virtual_attribute_name})
|
|
95
|
+
@registered_callbacks << -> { #{field_name}_transition_to(#{virtual_attribute_name}, **options) }
|
|
96
|
+
else
|
|
97
|
+
errors.add(:#{field_name}, :invalid_transition, message: "cannot transition from \#{#{field_name}} to \#{#{virtual_attribute_name}}")
|
|
98
|
+
return false
|
|
99
|
+
end
|
|
89
100
|
end
|
|
90
101
|
|
|
91
102
|
if defined?(super)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: statesman-multi_state
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chedli Bourguiba
|
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
76
76
|
- !ruby/object:Gem::Version
|
|
77
77
|
version: '0'
|
|
78
78
|
requirements: []
|
|
79
|
-
rubygems_version: 3.6.
|
|
79
|
+
rubygems_version: 3.6.9
|
|
80
80
|
specification_version: 4
|
|
81
81
|
summary: Rails/Statesman plugin that handle multiple state machines on the same model
|
|
82
82
|
through `has_one_state_machine` ActiveRecord macro
|