Class: T::Private::Types::TypeAlias

Inherits:
Types::Base show all
Defined in:
lib/types/private/types/type_alias.rb

Overview

Wraps a proc for a type alias to defer its evaluation.

Instance Method Summary collapse

Methods inherited from Types::Base

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

Constructor Details

#initialize(callable) ⇒ TypeAlias

Returns a new instance of TypeAlias.



8
9
10
# File 'lib/types/private/types/type_alias.rb', line 8

def initialize(callable)
  @callable = callable
end

Instance Method Details

#aliased_typeObject



16
17
18
# File 'lib/types/private/types/type_alias.rb', line 16

def aliased_type
  @aliased_type ||= T::Utils.coerce(@callable.call)
end

#build_typeObject



12
13
14
# File 'lib/types/private/types/type_alias.rb', line 12

def build_type
  nil
end

#nameObject

overrides Base



21
22
23
# File 'lib/types/private/types/type_alias.rb', line 21

def name
  aliased_type.name
end

#recursively_valid?(obj) ⇒ Boolean

overrides Base

Returns:



26
27
28
# File 'lib/types/private/types/type_alias.rb', line 26

def recursively_valid?(obj)
  aliased_type.recursively_valid?(obj)
end

#valid?(obj) ⇒ Boolean

overrides Base

Returns:



31
32
33
# File 'lib/types/private/types/type_alias.rb', line 31

def valid?(obj)
  aliased_type.valid?(obj)
end