lib/dry/transaction/result_matcher.rb in dry-transaction-0.6.0 vs lib/dry/transaction/result_matcher.rb in dry-transaction-0.7.0

- old
+ new

@@ -3,20 +3,24 @@ class ResultMatcher attr_reader :result attr_reader :output def initialize(result) - @result = result + if result.respond_to?(:to_either) + @result = result.to_either + else + @result = result + end end def success(&block) - return output unless result.is_a?(Kleisli::Either::Right) + return output unless result.right? @output = block.call(result.value) end def failure(step_name = nil, &block) - return output unless result.is_a?(Kleisli::Either::Left) + return output unless result.left? if step_name.nil? || step_name == result.value.__step_name @output = block.call(result.value) end end