Class: T::Types::TypedClass

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

Direct Known Subclasses

Anything, Untyped

Defined Under Namespace

Modules: Private Classes: Anything, Untyped

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(type) ⇒ TypedClass

Returns a new instance of TypedClass.



6
7
8
# File 'lib/types/types/typed_class.rb', line 6

def initialize(type)
  @inner_type = type
end

Instance Method Details

#build_typeObject



14
15
16
17
# File 'lib/types/types/typed_class.rb', line 14

def build_type
  type
  nil
end

#nameObject

overrides Base



20
21
22
# File 'lib/types/types/typed_class.rb', line 20

def name
  "T::Class[#{type.name}]"
end

#typeObject



10
11
12
# File 'lib/types/types/typed_class.rb', line 10

def type
  @type ||= T::Utils.coerce(@inner_type)
end

#underlying_classObject



24
25
26
# File 'lib/types/types/typed_class.rb', line 24

def underlying_class
  Class
end

#valid?(obj) ⇒ Boolean

overrides Base

Returns:



29
30
31
# File 'lib/types/types/typed_class.rb', line 29

def valid?(obj)
  Class.===(obj)
end