ronad 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +1 -0
- data/lib/ronad/just_one.rb +7 -2
- data/lib/ronad/maybe.rb +6 -0
- data/lib/ronad/sugar.rb +1 -1
- data/lib/ronad/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: 92c3fe5954c20636ef0adfda0823d73b1c3c91a9778bc6698d9be5538c22d402
|
4
|
+
data.tar.gz: de98fafde865cb62229efb3163c708349f15d2922e6cb860c75c6f69a005b9cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7da852fd7409736474db7734b38fb2ea2caa558830a26c12499bc6ede51bb8c59c24c896f344c24c3070dc3483015cdce40789eb6b14ea655a89028479b395b
|
7
|
+
data.tar.gz: 99b5d6de76fb2f78e204284170e71eccf792a6108421cc3cccc705eb4d31f685e284d003f90d6c7cd12a6f8b322d175acd7c344321dd2e6ff372cd67cb235f36
|
data/bin/console
CHANGED
data/lib/ronad/just_one.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
module Ronad
|
2
|
+
# @deprecated
|
3
|
+
# @see Ronad::Maybe::from_multiple_values
|
2
4
|
class JustOne < Just
|
3
|
-
def
|
4
|
-
|
5
|
+
def self.new(*args)
|
6
|
+
warn "[DEPRECATION] Ronad::JustOne is deprecated, see Ronad::Many::from_multiple_values."
|
7
|
+
raise CannotBeNil if args.compact.empty?
|
8
|
+
|
9
|
+
Just.new Maybe.from_multiple_values(*args)
|
5
10
|
end
|
6
11
|
end
|
7
12
|
end
|
data/lib/ronad/maybe.rb
CHANGED
@@ -2,6 +2,12 @@ require 'ronad/monad'
|
|
2
2
|
|
3
3
|
module Ronad
|
4
4
|
class Maybe < Monad
|
5
|
+
# Creates a single Maybe from multiple values, shorting on the first
|
6
|
+
# non-nil value.
|
7
|
+
def self.from_multiple_values(*vals)
|
8
|
+
new vals.detect { |v| Monad.new(v).value != nil }
|
9
|
+
end
|
10
|
+
|
5
11
|
# Allows for safe navigation on nil.
|
6
12
|
#
|
7
13
|
# nil&.m1&.m2&.m3 #=> nil
|
data/lib/ronad/sugar.rb
CHANGED
@@ -4,7 +4,7 @@ require 'ronad/just_one'
|
|
4
4
|
require 'ronad/default'
|
5
5
|
require 'ronad/eventually'
|
6
6
|
|
7
|
-
def Maybe(
|
7
|
+
def Maybe(*values) ; Ronad::Maybe.from_multiple_values(*values) end
|
8
8
|
def Just(value); Ronad::Just.new(value) end
|
9
9
|
def JustOne(*values); Ronad::JustOne.new(*values) end
|
10
10
|
def Default(fallback, value) ; Ronad::Default.new(fallback, value) end
|
data/lib/ronad/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ronad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uri Gorelik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|