servactory 2.4.0 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/servactory/context/callable.rb +5 -17
- data/lib/servactory/result.rb +7 -3
- data/lib/servactory/test_kit/result.rb +2 -2
- data/lib/servactory/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbf66d2c89ef6a0b50a80343230e56d940e41ce3754528cc902dbf17663800a7
|
4
|
+
data.tar.gz: dc302908e1305c9b9cbecacf1506fe9222db5e9b835fd0e8febb6e54e1211b92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9eb5b104b1ff966b92b2f656070379daf252d00921937383e094549bc3ae3a7782b6e43cbdec08051b38168a1d2d7f8e38d4b90e9c6a367828fd40c66218399
|
7
|
+
data.tar.gz: 2b51810de55de6b8a13ba4f7cc22e2ebd913839cd86fa68f05cec9c83b5558dbcba9bf13cf194f163287c5c7a0d7bab5bdf5a715b159106338611cc2d082c706
|
@@ -4,41 +4,29 @@ module Servactory
|
|
4
4
|
module Context
|
5
5
|
module Callable
|
6
6
|
def call!(arguments = {})
|
7
|
-
prepare_result_class
|
8
|
-
|
9
7
|
context = send(:new)
|
10
8
|
|
11
9
|
_call!(context, **arguments)
|
12
10
|
|
13
|
-
|
11
|
+
Servactory::Result.success_for(context: context)
|
14
12
|
rescue config.success_class => e
|
15
|
-
|
13
|
+
Servactory::Result.success_for(context: e.context)
|
16
14
|
end
|
17
15
|
|
18
16
|
def call(arguments = {})
|
19
|
-
prepare_result_class
|
20
|
-
|
21
17
|
context = send(:new)
|
22
18
|
|
23
19
|
_call!(context, **arguments)
|
24
20
|
|
25
|
-
|
21
|
+
Servactory::Result.success_for(context: context)
|
26
22
|
rescue config.success_class => e
|
27
|
-
|
23
|
+
Servactory::Result.success_for(context: e.context)
|
28
24
|
rescue config.failure_class => e
|
29
|
-
|
25
|
+
Servactory::Result.failure_for(context: context, exception: e)
|
30
26
|
end
|
31
27
|
|
32
28
|
private
|
33
29
|
|
34
|
-
def prepare_result_class
|
35
|
-
return if Object.const_defined?("#{name}::Result")
|
36
|
-
|
37
|
-
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
38
|
-
Result = Class.new(Servactory::Result)
|
39
|
-
RUBY
|
40
|
-
end
|
41
|
-
|
42
30
|
def _call!(context, **arguments)
|
43
31
|
context.send(
|
44
32
|
:_call!,
|
data/lib/servactory/result.rb
CHANGED
@@ -19,11 +19,11 @@ module Servactory
|
|
19
19
|
new(context: context).send(:as_success)
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.failure_for(exception:)
|
23
|
-
new(exception: exception).send(:as_failure)
|
22
|
+
def self.failure_for(context:, exception:)
|
23
|
+
new(context: context, exception: exception).send(:as_failure)
|
24
24
|
end
|
25
25
|
|
26
|
-
def initialize(context
|
26
|
+
def initialize(context:, exception: nil)
|
27
27
|
@context = context
|
28
28
|
@exception = exception
|
29
29
|
end
|
@@ -78,6 +78,10 @@ module Servactory
|
|
78
78
|
false
|
79
79
|
end
|
80
80
|
|
81
|
+
outputs.methods(false).each do |method_name|
|
82
|
+
define_singleton_method(method_name) { outputs.send(method_name) }
|
83
|
+
end
|
84
|
+
|
81
85
|
self
|
82
86
|
end
|
83
87
|
|
@@ -7,8 +7,8 @@ module Servactory
|
|
7
7
|
Servactory::Result.success_for(context: new(attributes))
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.as_failure(exception: nil)
|
11
|
-
Servactory::Result.failure_for(exception: exception)
|
10
|
+
def self.as_failure(attributes = {}, exception: nil)
|
11
|
+
Servactory::Result.failure_for(context: new(attributes), exception: exception)
|
12
12
|
end
|
13
13
|
|
14
14
|
def initialize(attributes = {})
|
data/lib/servactory/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|