Sha256: 8b0d1ba48a01284f20be4a55b6f8d927f5b41b56d9e649a601bb9484b5af9ae4

Contents?: true

Size: 417 Bytes

Versions: 6

Compression:

Stored size: 417 Bytes

Contents

module Dry
  module Transaction
    # @api private
    class Stack
      RETURN = -> x { x }

      def initialize(steps)
        @stack = compile(steps)
      end

      def call(m)
        @stack.(m)
      end

      private

      def compile(steps)
        steps.reverse.reduce(RETURN) do |next_step, step|
          proc { |m| m.bind { |value| step.(value, next_step) } }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-transaction-0.13.0 lib/dry/transaction/stack.rb
dry-transaction-0.12.1 lib/dry/transaction/stack.rb
dry-transaction-0.12.0 lib/dry/transaction/stack.rb
dry-transaction-0.11.2 lib/dry/transaction/stack.rb
dry-transaction-0.11.1 lib/dry/transaction/stack.rb
dry-transaction-0.11.0 lib/dry/transaction/stack.rb