Class: Tapioca::Runtime::GenericTypeRegistry::GenericType

Inherits:
T::Types::Base
  • Object
show all
Defined in:
lib/tapioca/runtime/generic_type_registry.rb

Overview

Subclasses T::Types::Base rather than T::Types::Simple so that all validation goes through the valid? override below. Simple fast paths check raw_type directly, which for us is the clone, not the underlying type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_type, underlying_type) ⇒ GenericType

: (Module raw_type, Module underlying_type) -> void



36
37
38
39
40
41
# File 'lib/tapioca/runtime/generic_type_registry.rb', line 36

def initialize(raw_type, underlying_type)
  super()

  @raw_type = raw_type
  @underlying_type = underlying_type #: Module[top]
end

Instance Attribute Details

#raw_type ⇒ Object (readonly)

: Module



33
34
35
# File 'lib/tapioca/runtime/generic_type_registry.rb', line 33

def raw_type
  @raw_type
end

Instance Method Details

#build_type ⇒ Object

: -> nil



57
58
59
# File 'lib/tapioca/runtime/generic_type_registry.rb', line 57

def build_type
  nil
end

#name ⇒ Object

: -> String



51
52
53
# File 'lib/tapioca/runtime/generic_type_registry.rb', line 51

def name
  T.must(@raw_type.name)
end

#valid?(obj) ⇒ Boolean

: (untyped obj) -> bool

Returns:

  • (Boolean)


45
46
47
# File 'lib/tapioca/runtime/generic_type_registry.rb', line 45

def valid?(obj)
  obj.is_a?(@underlying_type)
end