Sha256: dfec3ea65286325b0389102c967722d7124efe1415fdaccc70c8626732b1cf43

Contents?: true

Size: 543 Bytes

Versions: 3

Compression:

Stored size: 543 Bytes

Contents

require "dry/matcher"

module Dry
  module Transaction
    ResultMatcher = Dry::Matcher.new(
      success: Dry::Matcher::Case.new(
        match: -> result { result.right? },
        resolve: -> result { result.value }
      ),
      failure: Dry::Matcher::Case.new(
        match: -> result, step_name = nil {
          if step_name
            result.left? && result.value.step.step_name == step_name
          else
            result.left?
          end
        },
        resolve: -> result { result.value.value }
      )
    )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-transaction-0.10.2 lib/dry/transaction/result_matcher.rb
dry-transaction-0.10.1 lib/dry/transaction/result_matcher.rb
dry-transaction-0.10.0 lib/dry/transaction/result_matcher.rb