Module: Calculi::Attribute
- Defined in:
- lib/calculi/attribute.rb
Defined Under Namespace
Classes: Abstract, Boolean, Duration, Integer, Procable, String
Class Method Summary
collapse
Class Method Details
.lookup(type) ⇒ Object
3
4
5
6
7
8
9
10
11
|
# File 'lib/calculi/attribute.rb', line 3
def lookup(type)
if valid_type?(type)
type
elsif type.kind_of?(String) || type.kind_of?(Symbol)
type_from_string type
else
raise "Unknown attribute type: #{type}"
end
end
|
.type_from_string(type_name) ⇒ Object
17
18
19
20
21
|
# File 'lib/calculi/attribute.rb', line 17
def type_from_string(type_name)
type_name = type_name.to_s.classify.demodulize
"Calculi::Attribute::#{type_name}".constantize
end
|
.valid_type?(type_klass) ⇒ Boolean
13
14
15
|
# File 'lib/calculi/attribute.rb', line 13
def valid_type?(type_klass)
type_klass.kind_of?(Module) && type < Calculi::Attribute::Abstract
end
|