resonad 1.1.1 → 1.2.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/lib/resonad.rb +18 -4
- data/lib/resonad/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eee55274773363f0220a61e2d4714d11a129869
|
4
|
+
data.tar.gz: 05873de655e1cc85fe147e7b247788ad273f10d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34f5b90502c5737493195d5e44ed8b6686f1c9cb3145c240c09609db89deb5e577196e01ba55e3bdf3a9511d4107f996d8a26bbbcc7c4e55fc01f645956e312b
|
7
|
+
data.tar.gz: a1a80de205c720d7f2ba54e799b97ad7cb0da4edac82b5dfba6aba8ab4b1fa87d7133fc03f71d452b4c834cf9c399ee85f076696290bcccbc6e81e3ac9cda482
|
data/lib/resonad.rb
CHANGED
@@ -3,12 +3,20 @@ class Resonad
|
|
3
3
|
class NonExistentValue < StandardError; end
|
4
4
|
|
5
5
|
module Mixin
|
6
|
-
def Success(
|
7
|
-
|
6
|
+
def Success(value=nil)
|
7
|
+
if nil == value
|
8
|
+
NIL_SUCCESS
|
9
|
+
else
|
10
|
+
Success.new(value)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
|
-
def Failure(
|
11
|
-
|
14
|
+
def Failure(error=nil)
|
15
|
+
if nil == error
|
16
|
+
NIL_FAILURE
|
17
|
+
else
|
18
|
+
Failure.new(error)
|
19
|
+
end
|
12
20
|
end
|
13
21
|
end
|
14
22
|
extend Mixin
|
@@ -126,10 +134,14 @@ class Resonad
|
|
126
134
|
def success?
|
127
135
|
raise NotImplementedError, "should be implemented in subclass"
|
128
136
|
end
|
137
|
+
def successful?; success?; end
|
138
|
+
def ok?; success?; end
|
129
139
|
|
130
140
|
def failure?
|
131
141
|
not success?
|
132
142
|
end
|
143
|
+
def failed?; failure?; end
|
144
|
+
def bad?; failure?; end
|
133
145
|
|
134
146
|
def flat_map
|
135
147
|
raise NotImplementedError, "should be implemented in subclass"
|
@@ -141,4 +153,6 @@ class Resonad
|
|
141
153
|
end
|
142
154
|
def or_else(&block); flat_map_error(&block); end
|
143
155
|
|
156
|
+
NIL_SUCCESS = Success.new(nil)
|
157
|
+
NIL_FAILURE = Failure.new(nil)
|
144
158
|
end
|
data/lib/resonad/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resonad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Dalling
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|