Sha256: 8bbe3d2c5245b7d9cbce8d0e50dc30767d8f38dc210142a40031acf848876bf1

Contents?: true

Size: 603 Bytes

Versions: 2

Compression:

Stored size: 603 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Transaction
    # A wrapper for storing together the step that failed
    # and value describing the failure.
    class StepFailure
      attr_reader :step
      attr_reader :value

      # @api private
      def self.call(step, value)
        # rubocop:disable Style/CaseEquality
        if self === value
          value
        else
          yield
          new(step, value)
        end
        # rubocop:enable Style/CaseEquality
      end

      def initialize(step, value)
        @step = step
        @value = value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-transaction-0.16.0 lib/dry/transaction/step_failure.rb
dry-transaction-0.15.0 lib/dry/transaction/step_failure.rb