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



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

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

#nameObject

overrides Base



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

def name
  aliased_type.name
end

#recursively_valid?(obj) ⇒ Boolean

overrides Base

Returns:



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

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

#valid?(obj) ⇒ Boolean

overrides Base

Returns:



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

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