Module: Shale::Type
- Defined in:
- lib/shale/type.rb,
lib/shale/type/date.rb,
lib/shale/type/time.rb,
lib/shale/type/float.rb,
lib/shale/type/value.rb,
lib/shale/type/string.rb,
lib/shale/type/boolean.rb,
lib/shale/type/complex.rb,
lib/shale/type/decimal.rb,
lib/shale/type/integer.rb
Defined Under Namespace
Classes: Boolean, Complex, Date, Decimal, Float, Integer, String, Time, Value
Class Method Summary collapse
-
.lookup(type) ⇒ Shale::Type::Value
Lookup a Shale::Type::Value class by type alias.
-
.register(type, klass) ⇒ Object
Register a symbol alias for a Shale::Type::Value class.
Class Method Details
.lookup(type) ⇒ Shale::Type::Value
Lookup a Shale::Type::Value class by type alias
47 48 49 50 51 52 53 |
# File 'lib/shale/type.rb', line 47 def lookup(type) klass = @registry[type] raise UnknownTypeError, "unknown type '#{type}'" unless klass klass end |
.register(type, klass) ⇒ Object
Register a symbol alias for a Shale::Type::Value class
23 24 25 26 27 28 29 30 31 |
# File 'lib/shale/type.rb', line 23 def register(type, klass) @registry ||= {} unless klass < Value raise NotATypeValueError, "class '#{klass}' is not a valid Shale::Type::Value" end @registry[type] = klass end |