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 initialize(arg_types, returns)
def initialize(arg_types, returns) @arg_types = {} arg_types.each do |key, raw_type| @arg_types[key] = T::Utils.coerce(raw_type) end @returns = T::Utils.coerce(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 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| subtype_of?(a) && returns.subtype_of?(other.returns) e
def valid?(obj)
def valid?(obj) obj.is_a?(::Proc) end