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

Returns a new instance of TypedClass.



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

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

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#nameObject

overrides Base



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

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

#underlying_classObject



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

def underlying_class
  Class
end

#valid?(obj) ⇒ Boolean

overrides Base

Returns:



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

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