Class: T::Types::Simple

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

Overview

Validates that an object belongs to the specified class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initialize(raw_type) ⇒ Simple

Returns a new instance of Simple.



9
10
11
# File 'lib/types/types/simple.rb', line 9

def initialize(raw_type)
  @raw_type = raw_type
end

Instance Attribute Details

#raw_typeObject (readonly)

Returns the value of attribute raw_type.



7
8
9
# File 'lib/types/types/simple.rb', line 7

def raw_type
  @raw_type
end

Instance Method Details

#nameObject



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

def name
  @raw_type.name
end

#valid?(obj) ⇒ Boolean

Returns:



19
20
21
# File 'lib/types/types/simple.rb', line 19

def valid?(obj)
  obj.is_a?(@raw_type)
end