Class: T::Private::Types::TypeAlias
- Inherits:
-
Types::Base
- Object
- Types::Base
- T::Private::Types::TypeAlias
- 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
- #aliased_type ⇒ Object
- #build_type ⇒ Object
-
#initialize(callable) ⇒ TypeAlias
constructor
A new instance of TypeAlias.
-
#name ⇒ Object
overrides Base.
-
#recursively_valid?(obj) ⇒ Boolean
overrides Base.
-
#valid?(obj) ⇒ Boolean
overrides Base.
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_type ⇒ Object
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_type ⇒ Object
12 13 14 |
# File 'lib/types/private/types/type_alias.rb', line 12 def build_type nil end |
#name ⇒ Object
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
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
31 32 33 |
# File 'lib/types/private/types/type_alias.rb', line 31 def valid?(obj) aliased_type.valid?(obj) end |