resol 0.3.0 → 0.4.0
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/resol/result.rb +8 -0
- 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: cd11fdb0b0b5ddbc8db9593a530f0e19fe728f1ac58cc3dbb102868a52573f24
|
4
|
+
data.tar.gz: c628da55ad7e1847881c979b782dce7d973b23ace0f84ca20e1f528904c2fba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f4f0eff29c871470ac99506bb77738fe9bb7d6bf485b01d010973462659766e397c96915e7807aa15ffeb480e46738106ece879e8fdb4e5f76ad6170bceced5
|
7
|
+
data.tar.gz: a8d952cd3325b38b6b63f4066308c402b811fcdd6b2edd0e9d2d336ea15068bde3eb575add4d28cccd496b1f2978a7e1c4b96511851a4b387d7ced8f3b895551
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -99,6 +99,8 @@ Methods:
|
|
99
99
|
- `failure?` – returns `true` for failure result and `false` for success result
|
100
100
|
- `value!` – unwraps a result object, returns the value for success result, and throws an error for failure result
|
101
101
|
- `value_or(other_value, &block)` – returns a value for success result or `other_value` for failure result (either calls `block` in case it given)
|
102
|
+
- `or(&block)` - calls block for failure result, for success result does nothing
|
103
|
+
- `either(success_proc, failure_proc)` - for success result calls success_proc with result value in args, for failure result calls failure_proc with error in args.
|
102
104
|
|
103
105
|
|
104
106
|
### Configuration
|
data/lib/resol/result.rb
CHANGED
@@ -10,6 +10,14 @@ module Resol
|
|
10
10
|
# @!method value!
|
11
11
|
|
12
12
|
def initialize(*); end
|
13
|
+
|
14
|
+
def or
|
15
|
+
yield(@value) if failure?
|
16
|
+
end
|
17
|
+
|
18
|
+
def either(success_proc, failure_proc)
|
19
|
+
success? ? success_proc.call(@value) : failure_proc.call(@value)
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
15
23
|
class Success < Result
|
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.4.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-04-
|
11
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smart_initializer
|