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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fb9bdc62ea509b9a399e73085ee092022ae7b7c
4
- data.tar.gz: ec43b7e451ab8dd66555594bbef173fb847796e9
3
+ metadata.gz: 7eee55274773363f0220a61e2d4714d11a129869
4
+ data.tar.gz: 05873de655e1cc85fe147e7b247788ad273f10d9
5
5
  SHA512:
6
- metadata.gz: 8a04e80c7f93f45ac43b5502b21e9a55e20fc640fd52ce5bba1951b98a9794883351bc0e7bbf8f9e634c09fcf8f835641d4f97c856653e086466241b6b47653f
7
- data.tar.gz: e26eddbce9dd17b6fd569cb658a3122bc02ad6cff7b570e67bb7128f236f8568eb45400d52e07f9fb9957863dacaa7b5420439e79bf39148fa2ad38e07a3a2fc
6
+ metadata.gz: 34f5b90502c5737493195d5e44ed8b6686f1c9cb3145c240c09609db89deb5e577196e01ba55e3bdf3a9511d4107f996d8a26bbbcc7c4e55fc01f645956e312b
7
+ data.tar.gz: a1a80de205c720d7f2ba54e799b97ad7cb0da4edac82b5dfba6aba8ab4b1fa87d7133fc03f71d452b4c834cf9c399ee85f076696290bcccbc6e81e3ac9cda482
@@ -3,12 +3,20 @@ class Resonad
3
3
  class NonExistentValue < StandardError; end
4
4
 
5
5
  module Mixin
6
- def Success(*args)
7
- ::Resonad::Success.new(*args)
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(*args)
11
- ::Resonad::Failure.new(*args)
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
@@ -1,3 +1,3 @@
1
1
  class Resonad
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
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.1.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-09 00:00:00.000000000 Z
11
+ date: 2017-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler