tron 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tron.rb +17 -15
- data/lib/tron/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0231e5a13e707acc3ec83ffc50af2cb846b01c31ba8e2bb9fc105e78d30bd60e
|
4
|
+
data.tar.gz: b3ab4cd46c20a71bfc2673345f5da04ca0a388e2141c259387976952ddd7c983
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 187817f794d517f5c176f2c719344485df1afaca69cd32caf4e94b271f38a6a80e9dd0f328e2368bc0762985e7acf711b1f77c47fb77621e77e65080101a084f
|
7
|
+
data.tar.gz: 80811f5605325a75668bdbe9e8de95f18eb481ccd094e2f4b10f6a772b4fb483c876d34c06906b42e89ad8fafffea375d1620d4a0d111e4a1d40f067f34eed04
|
data/lib/tron.rb
CHANGED
@@ -2,24 +2,24 @@
|
|
2
2
|
|
3
3
|
require 'tron/version'
|
4
4
|
|
5
|
-
require 'tron/resultable' #
|
5
|
+
require 'tron/resultable' # Legacy
|
6
6
|
require 'tron/success' # Legacy
|
7
7
|
require 'tron/failure' # Legacy
|
8
8
|
|
9
9
|
module Tron
|
10
|
-
def self.success(code, attributes = {}) # rubocop:disable Metrics/MethodLength
|
10
|
+
def self.success(code, attributes = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
11
11
|
code.respond_to?(:to_sym) ||
|
12
12
|
raise(ArgumentError, 'Tron.success must be called with a Symbol as first argument')
|
13
13
|
|
14
14
|
attributes.respond_to?(:keys) ||
|
15
|
-
raise(ArgumentError, 'The
|
15
|
+
raise(ArgumentError, 'The second argument (metadata) for Tron.success must respond to #keys')
|
16
16
|
|
17
17
|
attributes.respond_to?(:values) ||
|
18
|
-
raise(ArgumentError, 'The
|
18
|
+
raise(ArgumentError, 'The second argument (metadata) for Tron.success must respond to #values')
|
19
19
|
|
20
20
|
Struct.new(:success, *attributes.keys) do
|
21
|
-
undef_method
|
22
|
-
members.each { |member| undef_method "#{member}="
|
21
|
+
undef_method :[]=
|
22
|
+
members.each { |member| undef_method :"#{member}=" }
|
23
23
|
|
24
24
|
def success?
|
25
25
|
true
|
@@ -34,7 +34,8 @@ module Tron
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def code
|
37
|
-
warn
|
37
|
+
warn 'DEPRECATION WARNING: Calling `#code` on a Tron object is deprecated and will be removed in Tron 2.0.0. ' \
|
38
|
+
"Please use `#success` instead. Called from `#{caller.first}`"
|
38
39
|
|
39
40
|
success
|
40
41
|
end
|
@@ -46,22 +47,22 @@ module Tron
|
|
46
47
|
def on_failure(_ = nil)
|
47
48
|
self
|
48
49
|
end
|
49
|
-
end.new code.to_sym, *attributes.values
|
50
|
+
end.new code.to_sym, *attributes.values
|
50
51
|
end
|
51
52
|
|
52
|
-
def self.failure(code, attributes = {}) # rubocop:disable Metrics/MethodLength
|
53
|
+
def self.failure(code, attributes = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
53
54
|
code.respond_to?(:to_sym) ||
|
54
55
|
raise(ArgumentError, 'Tron.failure must be called with a Symbol as first argument')
|
55
56
|
|
56
57
|
attributes.respond_to?(:keys) ||
|
57
|
-
raise(ArgumentError, 'The
|
58
|
+
raise(ArgumentError, 'The second argument (metadata) for Tron.failure must respond to #keys')
|
58
59
|
|
59
60
|
attributes.respond_to?(:values) ||
|
60
|
-
raise(ArgumentError, 'The
|
61
|
+
raise(ArgumentError, 'The second argument (metadata) for Tron.failure must respond to #values')
|
61
62
|
|
62
63
|
Struct.new(:failure, *attributes.keys) do
|
63
|
-
undef_method
|
64
|
-
members.each { |member| undef_method "#{member}="
|
64
|
+
undef_method :[]=
|
65
|
+
members.each { |member| undef_method :"#{member}=" }
|
65
66
|
|
66
67
|
def success?
|
67
68
|
false
|
@@ -76,7 +77,8 @@ module Tron
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def code
|
79
|
-
warn
|
80
|
+
warn 'DEPRECATION WARNING: Calling `#code` on a Tron object is deprecated and will be removed in Tron 2.0.0. ' \
|
81
|
+
"Please use `#failure` instead. Called from `#{caller.first}`"
|
80
82
|
|
81
83
|
failure
|
82
84
|
end
|
@@ -88,6 +90,6 @@ module Tron
|
|
88
90
|
def on_failure(proc = nil, &block)
|
89
91
|
(proc || block).call self
|
90
92
|
end
|
91
|
-
end.new code.to_sym, *attributes.values
|
93
|
+
end.new code.to_sym, *attributes.values
|
92
94
|
end
|
93
95
|
end
|
data/lib/tron/version.rb
CHANGED