Sha256: 3dafdd0b25ea7844da9e0e6bfb57af48c2619e2eb77e874ed9e8f1d7670a08da

Contents?: true

Size: 564 Bytes

Versions: 2

Compression:

Stored size: 564 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[step.operation_name] }

              [step.step_name, operation]
            }.to_h

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-transaction-0.10.1 lib/dry/transaction/operation_resolver.rb
dry-transaction-0.10.0 lib/dry/transaction/operation_resolver.rb