class Dry::ResultMatcher::Matcher

Attributes

output[R]
result[R]

Public Class Methods

new(result) click to toggle source
# File lib/dry/result_matcher/matcher.rb, line 9
def initialize(result)
  result = result.to_either if result.respond_to?(:to_either)
  @result = result
end

Public Instance Methods

failure(&block) click to toggle source
# File lib/dry/result_matcher/matcher.rb, line 19
def failure(&block)
  return output unless result.left?
  @output = block.call(result.value)
end
success(&block) click to toggle source
# File lib/dry/result_matcher/matcher.rb, line 14
def success(&block)
  return output unless result.right?
  @output = block.call(result.value)
end