Sha256: 59dc69cb2dbbb384f8d86af123cdc9b07cdaeec17c83e0ebbaf459484028f1fd

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

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.step_name) {
                ops_container and ops_container.key?(step.operation_name) and ops_container[step.operation_name]
              }

              [step.step_name, operation]
            }.to_h

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-transaction-0.10.2 lib/dry/transaction/operation_resolver.rb