Class: T::Types::TypeParameter

Inherits:
Base
  • Object
show all
Defined in:
lib/types/types/type_parameter.rb

Defined Under Namespace

Modules: Private

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #describe_obj, #error_message_for_obj, #error_message_for_obj_recursive, #hash, method_added, #recursively_valid?, #subtype_of?, #to_s, #validate!

Constructor Details

#initialize(name) ⇒ TypeParameter

Returns a new instance of TypeParameter.

Raises:

  • (ArgumentError)


18
19
20
21
# File 'lib/types/types/type_parameter.rb', line 18

def initialize(name)
  raise ArgumentError.new("not a symbol: #{name}") unless name.is_a?(Symbol)
  @name = name
end

Class Method Details

.make(name) ⇒ Object



23
24
25
26
27
28
# File 'lib/types/types/type_parameter.rb', line 23

def self.make(name)
  cached = Private.cached_entry(name)
  return cached if cached

  Private.set_entry_for(name, new(name))
end

Instance Method Details

#nameObject



38
39
40
# File 'lib/types/types/type_parameter.rb', line 38

def name
  "T.type_parameter(:#{@name})"
end

#subtype_of_single?(type) ⇒ Boolean

Returns:



34
35
36
# File 'lib/types/types/type_parameter.rb', line 34

def subtype_of_single?(type)
  true
end

#valid?(obj) ⇒ Boolean

Returns:



30
31
32
# File 'lib/types/types/type_parameter.rb', line 30

def valid?(obj)
  true
end