lab42_result 0.2.0 → 0.2.1
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/README.md +14 -2
- data/lib/lab42/result/errors.rb +8 -0
- data/lib/lab42/result/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: 37f73fc3956392012ee23253db6a75ebca8af75a06375ff213a80e169fc1a515
|
4
|
+
data.tar.gz: 28949c288301cef5477c122ae97dd9d020b60f0a65d00513563f4b04fd96cf8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a6827733845a78092efc9002136012671294dd385ba22c0bf39c239f923e491aaa06de80f06eeb1f77b9a9b26c5b06ff01d3d6941fa00a9c7c3f866c0663459
|
7
|
+
data.tar.gz: 5edf3309281f410ff35f2fee22652177d60b11b10619bbe999c007eb7a225a8127bd97992448a9f7037a4dbf9187e2ee5b6e9e9753165ceef3803b002676646b
|
data/README.md
CHANGED
@@ -83,7 +83,7 @@ And its value cannot be accessed anymore
|
|
83
83
|
|
84
84
|
But of course now we can call the error methods `#error` and `#exception`
|
85
85
|
```ruby
|
86
|
-
expect(error.error).to eq("oh no")
|
86
|
+
expect(error.error).to eq("oh no!")
|
87
87
|
expect(error.exception).to eq(RuntimeError)
|
88
88
|
|
89
89
|
```
|
@@ -252,7 +252,8 @@ As simple as that.
|
|
252
252
|
Now Result allows for a seamingless integration with this pattern, first of all it
|
253
253
|
exposes a module implementing it, but with a (more) reasonable name [Errors](lib/lab42/result/errors.rb)
|
254
254
|
|
255
|
-
|
255
|
+
While this makes for a fatter interface, if well used, can make the workflow
|
256
|
+
in your class more elegant
|
256
257
|
|
257
258
|
Given a class including Errors (pun intended)
|
258
259
|
```ruby
|
@@ -294,6 +295,17 @@ And eventually we get a helper to add many errors at once (always an optimist)
|
|
294
295
|
expect(errors).to eq([:error3, :error4])
|
295
296
|
```
|
296
297
|
|
298
|
+
But I kept my favorite at the end (bad misstake, the audience is sleeping already)
|
299
|
+
```ruby
|
300
|
+
great = MyErrors.new
|
301
|
+
output = []
|
302
|
+
great.if_ok { output << "I was completly fine" }
|
303
|
+
great.if_error { raise "Does not happen" }
|
304
|
+
great.add_errors("I got sick")
|
305
|
+
great.if_ok { raise "Still not happening" }
|
306
|
+
great.if_error { output << "But then, caught something" }
|
307
|
+
expect(output).to eq(["I was completly fine" , "But then, caught something"])
|
308
|
+
```
|
297
309
|
|
298
310
|
## Even more detailed speculations
|
299
311
|
|
data/lib/lab42/result/errors.rb
CHANGED
data/lib/lab42/result/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab42_result
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-01-
|
10
|
+
date: 2025-01-19 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: pry
|