ex_aequo_base 0.3.1 → 0.3.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38c439c3931527ea4afe7cf1d7b9d8f5cd3692cd06fdaac92ecd38ade6dd6e2a
|
4
|
+
data.tar.gz: b4a5b71ddc81ee3cf7a35c926e5c0626b668604e9627c0eff694ac3142d9459b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4454fbe184e912b030dd00c3227292028a0d36c945031941e06b61194667bb0c273f3a6c25fd34c1e47c0b7da115a06852e14302e6d1efd0db8f0242a5edb8c8
|
7
|
+
data.tar.gz: 5765d441edadab1920aed6c8c1a617791df46ff508b8101f27c91b8a52b8ee81d1bebacb165155b5ad6f7f8aeec78a934dc1a401102f42c3ca2ad5a0e8ef721a
|
@@ -4,29 +4,36 @@ module ExAequo
|
|
4
4
|
module Base
|
5
5
|
class Result
|
6
6
|
module ClassMethods
|
7
|
+
def from_value(value, error: nil)
|
8
|
+
if value
|
9
|
+
ok(value)
|
10
|
+
else
|
11
|
+
nok(error)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
def new(*, **) = raise NoMethodError, "undefined method 'new' for #<Class:Result>"
|
8
16
|
|
9
|
-
def
|
17
|
+
def nok(error)
|
10
18
|
allocate.tap do |object|
|
11
19
|
object.instance_eval do
|
12
|
-
@ok =
|
13
|
-
@
|
20
|
+
@ok = false
|
21
|
+
@error = error
|
14
22
|
end
|
15
23
|
end
|
16
24
|
end
|
25
|
+
alias_method :failure, :nok
|
17
26
|
|
18
|
-
alias_method :success, :ok
|
19
27
|
|
20
|
-
def
|
28
|
+
def ok(result)
|
21
29
|
allocate.tap do |object|
|
22
30
|
object.instance_eval do
|
23
|
-
@ok =
|
24
|
-
@
|
31
|
+
@ok = true
|
32
|
+
@result = result
|
25
33
|
end
|
26
34
|
end
|
27
35
|
end
|
28
|
-
|
29
|
-
alias_method :failure, :nok
|
36
|
+
alias_method :success, :ok
|
30
37
|
|
31
38
|
end
|
32
39
|
|
data/lib/ex_aequo/base/result.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ex_aequo_base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/ex_aequo/base/regexp.rb
|
73
73
|
- lib/ex_aequo/base/result.rb
|
74
74
|
- lib/ex_aequo/base/result/class_methods.rb
|
75
|
+
- lib/ex_aequo/base/result/import.rb
|
75
76
|
- lib/ex_aequo/base/string.rb
|
76
77
|
- lib/ex_aequo/base/to_proc.rb
|
77
78
|
- lib/ex_aequo/base/to_proc/false_class.rb
|