class T::Types::Proc
keyword arguments.
At present, we only support fixed-arity procs with no optional or
validates that the value is a ‘::Proc`.
Defines the type of a proc (a ruby callable). At runtime, only
def arg_types
def arg_types @arg_types ||= @inner_arg_types.transform_values do |raw_type| T::Utils.coerce(raw_type) end end
def build_type
def build_type arg_types returns nil end
def initialize(arg_types, returns)
def initialize(arg_types, returns) @inner_arg_types = arg_types @inner_returns = returns end
def name
def name args = [] arg_types.each do |k, v| args << "#{k}: #{v.name}" end "T.proc.params(#{args.join(', ')}).returns(#{returns})" end
def returns
def returns @returns ||= T::Utils.coerce(@inner_returns) end
def subtype_of_single?(other)
def subtype_of_single?(other) ther elf.class rg_types.size != other.arg_types.size turn false types.values.zip(other.arg_types.values).all? do |a, b| .nil? && b.subtype_of?(a) && returns.subtype_of?(other.returns) e
def valid?(obj)
def valid?(obj) obj.is_a?(::Proc) end