dry-mutations 0.8.95 → 0.8.98
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dry/mutations/extensions/outcome.rb +17 -6
- data/lib/dry/mutations/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b80a530afd1c61d67a42c30dff68c110bcfa9d2
|
4
|
+
data.tar.gz: bf5131d90014289ca96734bd375db7926e516446
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 644df92df56e36d80539363d9eb94650ac158b597f1fc34a7c0aba61a061cfe62ae81b75bc4026487690300ac2eddfa2ec7b832c9e6e005032faf78dc3287f05
|
7
|
+
data.tar.gz: 91a4705b8789f241e216c684588b8bf891bf0482fb5bb4d165db1640c15866b7c985ac2c26027e0a463dad5d8046452cca2247a1e36e044d5e5964d840d7f17f
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Dry
|
2
2
|
module Mutations
|
3
3
|
module Extensions # :nodoc:
|
4
|
-
module
|
4
|
+
module Either # :nodoc:
|
5
5
|
include Dry::Monads::Either::Mixin
|
6
6
|
|
7
7
|
class EitherCalculator # :nodoc:
|
@@ -69,12 +69,22 @@ module Dry
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def match
|
72
|
-
fail
|
72
|
+
fail "Call to #{self.class.name}#match requires a block passed." unless block_given?
|
73
73
|
Matcher.!.(self, &Proc.new)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
# rubocop:disable Style/MethodName
|
78
|
+
def self.Either input
|
79
|
+
case input
|
80
|
+
when Class then input.prepend Either unless input.ancestors.include?(Either)
|
81
|
+
when Module then input.include Either unless input.ancestors.include?(Either)
|
82
|
+
else input.singleton_class.prepend Either unless input.singleton_class.ancestors.include?(Either)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
Either(::Mutations::Outcome)
|
87
|
+
Either(::Dry::Validation::Result)
|
78
88
|
|
79
89
|
def self.Outcome input
|
80
90
|
case input
|
@@ -90,10 +100,11 @@ module Dry
|
|
90
100
|
end
|
91
101
|
|
92
102
|
def self.Outcome! input
|
93
|
-
|
94
|
-
|
95
|
-
|
103
|
+
Outcome(input).tap do |outcome|
|
104
|
+
fail ::Mutations::ValidationException.new(outcome.errors) unless outcome.success?
|
105
|
+
end.value
|
96
106
|
end
|
107
|
+
# rubocop:enable Style/MethodName
|
97
108
|
end
|
98
109
|
end
|
99
110
|
end
|