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

Coercion with a publicly accessible method call

@api private

Public Class Methods

call_interface(method, safe) click to toggle source

Choose or build the interface

@return [::Module]

# File lib/dry/types/constructor/function.rb, line 59
            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, &block)              # def call(input, &block)
                        @target.#{method}(input, &block)   #   @target.coerve(input, &block)
                      end                                  # end
                    RUBY
                  else
                    module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
                      def call(input, &block)                                        # def call(input, &block)
                        @target.#{method}(input)                                     #   @target.coerce(input)
                      rescue ::NoMethodError, ::TypeError, ::ArgumentError => error  # rescue ::NoMethodError, ::TypeError, ::ArgumentError => error
                        CoercionError.handle(error, &block)                          #   CoercionError.handle(error, &block)
                      end                                                            # end
                    RUBY
                  end
                end
              end
            end