dry-mutations 0.8.95 → 0.8.98

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: ab34cce7ae7dae0a65fb5c0deae32a5b58d80b4d
4
- data.tar.gz: 807b22566a844bded55c9fbf8f3cde5f02e6926f
3
+ metadata.gz: 1b80a530afd1c61d67a42c30dff68c110bcfa9d2
4
+ data.tar.gz: bf5131d90014289ca96734bd375db7926e516446
5
5
  SHA512:
6
- metadata.gz: c9bf7564f9c36b9bb5b4219355f142c688813663936d1d2dfd123e56045b525c90faab9876fbad350e88c27c53966e51dc14ddc5487b4ae1ef41d26a93f0c7d1
7
- data.tar.gz: c2f1299819df0f7bcce26cf41c718e03447e12a0e034d49cc39538225537cbefce6c8e844529e1faff5bf99f1945132bc342f1b7372e6cab50c42c3a9911b4af
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 Outcome # :nodoc:
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 'Call to Outcome#match requires a block passed.' unless block_given?
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
- ::Mutations::Outcome.prepend Outcome unless ::Mutations::Outcome.ancestors.include?(Outcome)
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
- outcome = Outcome(input)
94
- raise ::Mutations::ValidationException.new(outcome.errors) unless outcome.success?
95
- outcome.value
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
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Mutations
3
- VERSION = '0.8.95'.freeze
3
+ VERSION = '0.8.98'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-mutations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.95
4
+ version: 0.8.98
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksei Matiushkin