resol 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95f5ea4fd61a180568a08289a20f53847d1709e70c07623086eb588948afa71e
4
- data.tar.gz: b425c633f442b13ff8885b840fa792b94f28a6df9037581fe0def1aa7feeffd6
3
+ metadata.gz: cd11fdb0b0b5ddbc8db9593a530f0e19fe728f1ac58cc3dbb102868a52573f24
4
+ data.tar.gz: c628da55ad7e1847881c979b782dce7d973b23ace0f84ca20e1f528904c2fba9
5
5
  SHA512:
6
- metadata.gz: cb48dfe79e77f5ee8bbc71c2c7438d2d414ab72fb428d634dc424d81d4bb7e5be940af252bd5bce2096c216e45e2872c081111c31eb3a3b8863db1eac565acec
7
- data.tar.gz: de35e8196047e2af8100be471f1ec1fb1c2a920994215483fac1865089e19b9a5ee09112c0544041bf41f02471208be40ef5c3dace4b7756019dfb963b18eb1a
6
+ metadata.gz: 6f4f0eff29c871470ac99506bb77738fe9bb7d6bf485b01d010973462659766e397c96915e7807aa15ffeb480e46738106ece879e8fdb4e5f76ad6170bceced5
7
+ data.tar.gz: a8d952cd3325b38b6b63f4066308c402b811fcdd6b2edd0e9d2d336ea15068bde3eb575add4d28cccd496b1f2978a7e1c4b96511851a4b387d7ced8f3b895551
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- resol (0.3.0)
4
+ resol (0.4.0)
5
5
  smart_initializer (~> 0.5)
6
6
  uber (~> 0.1)
7
7
 
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resol
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
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.3.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-20 00:00:00.000000000 Z
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_initializer