argon 1.1.5 → 1.2.0
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 +4 -4
- data/lib/argon.rb +15 -7
- data/lib/argon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b09160785840c5182b6b589f4d5f54b0d63195a1
|
4
|
+
data.tar.gz: 5a41ae363e257e607726e453304da872849546b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1f0d95b2405e163b88c8a07f7636fe9150fe8be919220ed97505efc1cc8bbe7d5dd3aff08cfc26c16960c6410703b1c1246e209699971e2d8afd76eae79ac5b
|
7
|
+
data.tar.gz: a6ff9a9fc30fafc0f44e9b4c7be3ddcbef2493f04c8b4878f13a5ac68b5deee39942396f6ef4f20cd1ca5df84d996a6db9543cf5894c78e2096a07be0f07f56d
|
data/lib/argon.rb
CHANGED
@@ -103,11 +103,13 @@ module Argon
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
raise Argon::Error.new("`on_successful_transition` must be a
|
107
|
-
raise Argon::Error.new("`on_successful_transition` must be a
|
106
|
+
raise Argon::Error.new("`on_successful_transition` must be a boolean") unless [true, false].include?(on_successful_transition)
|
107
|
+
raise Argon::Error.new("`on_successful_transition` must be a method of signature `(field:, action:, from:, to:)`") if on_successful_transition && !self.instance_methods.include?(:on_successful_transition)
|
108
|
+
raise Argon::Error.new("`on_successful_transition` must be a method of signature `(field:, action:, from:, to:)`") if on_successful_transition && self.instance_method(:on_successful_transition).parameters.to_set != %i(field action from to).map{|f| [:keyreq, f] }.to_set
|
108
109
|
|
109
|
-
raise Argon::Error.new("`on_failed_transition` must be a
|
110
|
-
raise Argon::Error.new("`on_failed_transition` must be a
|
110
|
+
raise Argon::Error.new("`on_failed_transition` must be a boolean") unless [true, false].include?(on_failed_transition)
|
111
|
+
raise Argon::Error.new("`on_failed_transition` must be a method of signature `(field:, action:, from:, to:)`") if on_failed_transition && !self.instance_methods.include?(:on_failed_transition)
|
112
|
+
raise Argon::Error.new("`on_failed_transition` must be a method of signature `(field:, action:, from:, to:)`") if on_failed_transition && self.instance_method(:on_failed_transition).parameters.to_set != %i(field action from to).map{|f| [:keyreq, f] }.to_set
|
111
113
|
|
112
114
|
events_list.each do |event_name|
|
113
115
|
end
|
@@ -158,7 +160,9 @@ module Argon
|
|
158
160
|
end
|
159
161
|
|
160
162
|
if self.send(field) != from
|
161
|
-
on_failed_transition
|
163
|
+
if on_failed_transition
|
164
|
+
self.on_failed_transition(field: field, action: action, from: from, to: to)
|
165
|
+
end
|
162
166
|
raise Argon::InvalidTransitionError.new("Invalid state transition")
|
163
167
|
end
|
164
168
|
|
@@ -184,11 +188,15 @@ module Argon
|
|
184
188
|
end
|
185
189
|
end
|
186
190
|
rescue => e
|
187
|
-
on_failed_transition
|
191
|
+
if on_failed_transition
|
192
|
+
self.on_failed_transition(field: field, action: action, from: from, to: to)
|
193
|
+
end
|
188
194
|
raise e
|
189
195
|
end
|
190
196
|
|
191
|
-
on_successful_transition
|
197
|
+
if on_successful_transition
|
198
|
+
self.on_successful_transition(field: field, action: action, from: from, to: to)
|
199
|
+
end
|
192
200
|
|
193
201
|
unless after_lock_callback.nil?
|
194
202
|
if args.empty?
|
data/lib/argon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: argon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ajith Hussain
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|