u-service 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/micro/service/pipeline.rb +2 -3
- data/lib/micro/service/result.rb +18 -11
- data/lib/micro/service/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6318b522443f18f20b9cc6d6df3df66bac3b47ec00c0cf634c8e5093cd1e9c8
|
4
|
+
data.tar.gz: abe048fdae03253fca5e46ef35a7c95c104bdafedb32358983533470a46958b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 020b873f0b7c0326b5ad26c72c64a412ec4383709d626804af0147e2a80a9274a41228cb100332a41f12400c96a4251a8c900fe13851bf4ffaabbe7874ce488c
|
7
|
+
data.tar.gz: d17ba3915f0fa3d1d69e0b02f46f0a14d44ea707255a78a3ac9386a9cf14e86201832b3f3c04cd3e4ead9f93323123092b752fcab5218355e538ecbcd4f9738e
|
data/Gemfile.lock
CHANGED
@@ -15,11 +15,10 @@ module Micro
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(arg={})
|
18
|
-
|
18
|
+
initial_result = Micro::Service::Result::Success(value: arg)
|
19
19
|
|
20
|
-
@services.reduce(
|
20
|
+
@services.reduce(initial_result) do |result, service|
|
21
21
|
break result if result.failure?
|
22
|
-
|
23
22
|
service.call(result.value)
|
24
23
|
end
|
25
24
|
end
|
data/lib/micro/service/result.rb
CHANGED
@@ -5,15 +5,22 @@ module Micro
|
|
5
5
|
class Result
|
6
6
|
include Micro::Attributes.with(:initialize)
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
attributes :success, :type, :value
|
9
|
+
|
10
|
+
INVALID_TYPE = "#{self.name}#type must be nil or a symbol".freeze
|
11
|
+
|
12
|
+
def self.Type(arg)
|
13
|
+
return arg if arg.nil? || arg.is_a?(Symbol)
|
14
|
+
raise TypeError, INVALID_TYPE
|
10
15
|
end
|
11
16
|
|
12
|
-
def self.
|
13
|
-
self.new(success:
|
17
|
+
def self.Success(value:, type: nil)
|
18
|
+
self.new(success: true, type: Type(type), value: value)
|
14
19
|
end
|
15
20
|
|
16
|
-
|
21
|
+
def self.Failure(value:, type: nil)
|
22
|
+
self.new(success: false, type: Type(type), value: value)
|
23
|
+
end
|
17
24
|
|
18
25
|
def success?
|
19
26
|
success
|
@@ -44,14 +51,14 @@ module Micro
|
|
44
51
|
module Helpers
|
45
52
|
private
|
46
53
|
|
47
|
-
def Success(
|
48
|
-
|
49
|
-
Result::Success(
|
54
|
+
def Success(arg=nil)
|
55
|
+
value, type = block_given? ? [yield, arg] : [arg, nil]
|
56
|
+
Result::Success(value: value, type: type)
|
50
57
|
end
|
51
58
|
|
52
|
-
def Failure(
|
53
|
-
|
54
|
-
Result::Failure(
|
59
|
+
def Failure(arg=nil)
|
60
|
+
value, type = block_given? ? [yield, arg] : [arg, nil]
|
61
|
+
Result::Failure(value: value, type: type)
|
55
62
|
end
|
56
63
|
end
|
57
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: u-service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Serradura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: u-attributes
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
rubygems_version: 3.0.
|
113
|
+
rubygems_version: 3.0.3
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: Create simple and powerful service objects.
|