Sha256: 23c11637e8506c4c957b95583dac0e143f87416d593960a524d9257039bd53a7

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 Bytes

Contents

require "dry/matcher"

module Dry
  class Matcher
    EitherMatcher = Dry::Matcher.new(
      success: Case.new(
        match: -> result, *pattern {
          result = result.to_either
          result.right?
        },
        resolve: -> result {
          result = result.to_either
          result.value
        },
      ),
      failure: Case.new(
        match: -> result, *pattern {
          result = result.to_either
          result.left?
        },
        resolve: -> result {
          result = result.to_either
          result.value
        },
      )
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-matcher-0.5.0 lib/dry/matcher/either_matcher.rb