Class: Camille::Type
Overview
This class represents all custom types defined by the user.
Defined Under Namespace
Classes: NotImplementedError
Instance Attribute Summary collapse
Attributes inherited from BasicType
#fingerprint
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BasicType
&, #&, #[], [], directly_instantiable?, instance, |, #|
Constructor Details
#initialize ⇒ Type
Returns a new instance of Type.
8
9
10
|
# File 'lib/camille/type.rb', line 8
def initialize
raise NotImplementedError.new("Missing `alias_of` definition for type.")
end
|
Instance Attribute Details
#underlying ⇒ Object
Returns the value of attribute underlying.
6
7
8
|
# File 'lib/camille/type.rb', line 6
def underlying
@underlying
end
|
Class Method Details
.alias_of(type) ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/camille/type.rb', line 12
def self.alias_of type
underlying = Camille::Type.instance(type)
fingerprint = underlying.fingerprint
define_method(:initialize) do
@underlying = underlying
@fingerprint = fingerprint
end
end
|
.check(value) ⇒ Object
30
31
32
|
# File 'lib/camille/type.rb', line 30
def self.check value
new.check value
end
|
.check_params(value) ⇒ Object
34
35
36
|
# File 'lib/camille/type.rb', line 34
def self.check_params value
new.check_params value
end
|
.inherited(klass) ⇒ Object
46
47
48
|
# File 'lib/camille/type.rb', line 46
def self.inherited klass
Camille::Loader.loaded_types << klass
end
|
.klass_name ⇒ Object
38
39
40
|
# File 'lib/camille/type.rb', line 38
def self.klass_name
name.gsub(/^Camille::Types::/, '')
end
|
Instance Method Details
#check(value) ⇒ Object
22
23
24
|
# File 'lib/camille/type.rb', line 22
def check value
@underlying.check value
end
|
#check_params(value) ⇒ Object
26
27
28
|
# File 'lib/camille/type.rb', line 26
def check_params value
@underlying.check_params value
end
|
#literal ⇒ Object
42
43
44
|
# File 'lib/camille/type.rb', line 42
def literal
self.class.klass_name.gsub(/::/, '_')
end
|