resol 0.5.1 → 0.6.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 +2 -2
- data/lib/resol/service.rb +14 -25
- data/lib/resol/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: 88557b0033bec108dc7f19bf2d6bd4bd7c7edbd79f6cd4f23257c9bc5b23856d
|
4
|
+
data.tar.gz: 3d25ee143170fd03b32421a560e7f6f3d353d2ced93f53748c9931ae1a10fcb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7424a06501000c75fe95e5f0b4397235594d8d0bbb2b16224ea0a5e456831e0c0b7e70c7a37d04a6bc43e1521e2a1585a711894ed11b6bf38a6f74a6e5583a0
|
7
|
+
data.tar.gz: 6c02d8eb6bb3d87f63ea4481f6d95b08a6c33e186ae501756443eee235eef2d1f358c677e99cdddcbf4bf431eed592fde9720087597905777cbcffb56514b010
|
data/Gemfile.lock
CHANGED
data/lib/resol/service.rb
CHANGED
@@ -8,58 +8,47 @@ module Resol
|
|
8
8
|
class Service
|
9
9
|
class InvalidCommandImplementation < StandardError; end
|
10
10
|
|
11
|
-
class
|
12
|
-
attr_accessor :data
|
11
|
+
class Failure < StandardError
|
12
|
+
attr_accessor :data, :code
|
13
13
|
|
14
|
-
def initialize(data)
|
14
|
+
def initialize(code, data)
|
15
|
+
self.code = code
|
15
16
|
self.data = data
|
16
|
-
super
|
17
|
+
super(data)
|
17
18
|
end
|
18
19
|
|
19
20
|
def inspect
|
20
21
|
"#{self.class.name}: #{message}"
|
21
22
|
end
|
22
23
|
|
23
|
-
def message
|
24
|
-
data.inspect
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class Failure < Interruption
|
29
|
-
attr_accessor :code
|
30
|
-
|
31
|
-
def initialize(code, data)
|
32
|
-
self.code = code
|
33
|
-
super(data)
|
34
|
-
end
|
35
|
-
|
36
24
|
def message
|
37
25
|
data ? "#{code.inspect} => #{data.inspect}" : code.inspect
|
38
26
|
end
|
39
27
|
end
|
40
28
|
|
41
|
-
class Success < Interruption; end
|
42
|
-
|
43
29
|
include SmartCore::Initializer
|
44
30
|
include Resol::Builder
|
45
31
|
include Resol::Callbacks
|
46
32
|
|
33
|
+
Result = Struct.new(:data)
|
34
|
+
|
47
35
|
class << self
|
48
36
|
def inherited(klass)
|
49
37
|
klass.const_set(:Failure, Class.new(klass::Failure))
|
50
|
-
klass.const_set(:Success, Class.new(klass::Success))
|
51
38
|
super
|
52
39
|
end
|
53
40
|
|
54
41
|
def call(*args, **kwargs, &block)
|
55
42
|
command = build(*args, **kwargs)
|
56
|
-
|
57
|
-
|
43
|
+
result = catch(command) do
|
44
|
+
__run_callbacks__(command)
|
45
|
+
command.call(&block)
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
return Resol::Success(result.data) unless result.nil?
|
58
49
|
|
59
50
|
error_message = "No success! or fail! called in the #call method in #{command.class}"
|
60
51
|
raise InvalidCommandImplementation, error_message
|
61
|
-
rescue self::Success => e
|
62
|
-
Resol::Success(e.data)
|
63
52
|
rescue self::Failure => e
|
64
53
|
Resol::Failure(e)
|
65
54
|
end
|
@@ -78,7 +67,7 @@ module Resol
|
|
78
67
|
end
|
79
68
|
|
80
69
|
def success!(data = nil)
|
81
|
-
|
70
|
+
throw(self, Result.new(data))
|
82
71
|
end
|
83
72
|
end
|
84
73
|
end
|
data/lib/resol/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksei Bespalov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smart_initializer
|