monad-oxide 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/err.rb +10 -0
- data/lib/ok.rb +11 -0
- data/lib/result.rb +11 -0
- data/lib/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: 7c37567d8988443ab1076e07e5784fa454f430a12400acbb15526de2164a2686
|
4
|
+
data.tar.gz: a09be57539e071b3094b1d052cff724f0b71e8ae22ecd3ed151ffc355984b041
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0b562a479e20ec1f488fe476c60c1c7138aa62f67b9cb83ca526ce0ff4e97a8c193d75062a175a466e877ae27b163ab9162cf72352126122035aa397024ac88
|
7
|
+
data.tar.gz: a78393ad99ebe353b9a9ccdbc31756e87a9578e768fa4b47fbef1bd756b08baa131b52ff69129a502d503e40daa44df283b678ec0ac26f5738b3bce562f003c9
|
data/lib/err.rb
CHANGED
@@ -166,5 +166,15 @@ module MonadOxide
|
|
166
166
|
@data
|
167
167
|
end
|
168
168
|
|
169
|
+
##
|
170
|
+
# Safely unwrap the `Result`. In the case of `Err`, this returns the
|
171
|
+
# provided default value.
|
172
|
+
#
|
173
|
+
# @param [T] x The value that will be returned.
|
174
|
+
# @return [T] The `x` value.
|
175
|
+
def unwrap_or(x)
|
176
|
+
x
|
177
|
+
end
|
178
|
+
|
169
179
|
end
|
170
180
|
end
|
data/lib/ok.rb
CHANGED
@@ -123,5 +123,16 @@ module MonadOxide
|
|
123
123
|
"#{self.class} with #{@data.inspect} could not be unwrapped as an Err.",
|
124
124
|
)
|
125
125
|
end
|
126
|
+
|
127
|
+
##
|
128
|
+
# Safely unwrap the `Result`. In the case of `Ok`, this returns the
|
129
|
+
# data in the Ok.
|
130
|
+
#
|
131
|
+
# @param [B] x The value that will be returned.
|
132
|
+
# @return [A] The data in the Ok.
|
133
|
+
def unwrap_or(_)
|
134
|
+
@data
|
135
|
+
end
|
136
|
+
|
126
137
|
end
|
127
138
|
end
|
data/lib/result.rb
CHANGED
@@ -225,5 +225,16 @@ module MonadOxide
|
|
225
225
|
def unwrap_err()
|
226
226
|
Err.new(ResultMethodNotImplementedError.new())
|
227
227
|
end
|
228
|
+
|
229
|
+
##
|
230
|
+
# Attempt to safely access the `Result` data. This always returns a value
|
231
|
+
# instead of raising an Exception. In the case of `Ok`, the data is
|
232
|
+
# returned. In the case of `Err`, the value provided is returned.
|
233
|
+
# @param _ [B] The value to use for `Err`.
|
234
|
+
# @return [T|B] The inner data of this `Ok` or the passee value.
|
235
|
+
def unwrap_or(_)
|
236
|
+
Err.new(ResultMethodNotImplementedError.new())
|
237
|
+
end
|
238
|
+
|
228
239
|
end
|
229
240
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monad-oxide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logan Barnett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: org-ruby
|