Sha256: 50bde139f1bd71fe7ed8c8589e8612baefe2701d6b5b605d56bff4ae825de2b8

Contents?: true

Size: 738 Bytes

Versions: 4

Compression:

Stored size: 738 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Transaction
    class OperationResolver < Module
      def initialize(container)
        module_exec(container) do |ops_container|
          define_method :initialize do |**kwargs|
            operation_kwargs = self.class.steps.select(&:operation_name).map { |step|
              operation = kwargs.fetch(step.name) {
                if ops_container && ops_container.key?(step.operation_name)
                  ops_container[step.operation_name]
                else
                  nil
                end
              }

              [step.name, operation]
            }.to_h

            super(**kwargs, **operation_kwargs)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-transaction-0.14.0 lib/dry/transaction/operation_resolver.rb
dry-transaction-0.13.3 lib/dry/transaction/operation_resolver.rb
dry-transaction-0.13.2 lib/dry/transaction/operation_resolver.rb
dry-transaction-0.13.1 lib/dry/transaction/operation_resolver.rb