am-kantox/dry-mutations

View on GitHub
lib/dry/mutations/transactions/container.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Dry
  module Mutations
    module Transactions # :nodoc:
      # rubocop:disable Style/MultilineTernaryOperator
      Container = lambda do |whatever|
        return ->(*input) { input } unless whatever
        whatever.respond_to?(:call) ? whatever : Utils.Constant(whatever).tap do |p|
          fail ArgumentError, "The argument must respond to :call, though #{whatever.inspect} passed." unless p.respond_to? :call
        end
      end
      # rubocop:enable Style/MultilineTernaryOperator
    end
  end
end