class Dry::Types::Constructor::Function::MethodCall::PublicCall

@api private
Coercion with a publicly accessible method call

def self.call_interface(method, safe)

Returns:
  • (::Module) -
def self.call_interface(method, safe)
  @interfaces.fetch_or_store([method, safe]) do
    ::Module.new do
      if safe
        module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
          def call(input, &)             # def call(input, &)
            @target.#{method}(input, &)  #   @target.coerce(input, &)
          end                            # end
        RUBY
      else
        module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
          def call(input, &)                                             # def call(input, &)
            @target.#{method}(input)                                     #   @target.coerce(input)
          rescue ::NoMethodError, ::TypeError, ::ArgumentError => error  # rescue ::NoMethodError, ::TypeError, ::ArgumentError => error
            CoercionError.handle(error, &)                               #   CoercionError.handle(error, &)
          end                                                            # end
        RUBY
      end
    end
  end
end