Class: Cequel::Type::Base Abstract
- Inherits:
-
Object
- Object
- Cequel::Type::Base
- Includes:
- Singleton
- Defined in:
- lib/cequel/type.rb
Overview
Subclasses should implement #cast, and may implement #internal_names if it cannot be inferred from the class name. The name of the type class should be the camel-cased CQL name of the type
The base class for all type objects. Types are singletons.
Instance Method Summary collapse
-
#cast(value) ⇒ Object
The value cast to the correct Ruby class for this type.
-
#compatible_types ⇒ Array<Type>
CQL only allows changing column types when the old type’s binary representation is compatible with the new type.
-
#cql_aliases ⇒ Array<Symbol>
Other names used in CQL for this type.
-
#cql_name ⇒ Object
The name of the type used in CQL.
-
#internal_name ⇒ Array<String>
deprecated
Deprecated.
use #internal_names
-
#internal_names ⇒ Array<String>
Full class name(s) of this type used in Cassandra’s underlying representation (allows for multiple values for types that have different names between different versions).
-
#to_s ⇒ Object
A string representation of this type.
Instance Method Details
#cast(value) ⇒ Object
Returns the value cast to the correct Ruby class for this type.
151 152 153 |
# File 'lib/cequel/type.rb', line 151 def cast(value) value end |
#compatible_types ⇒ Array<Type>
CQL only allows changing column types when the old type’s binary representation is compatible with the new type.
162 163 164 |
# File 'lib/cequel/type.rb', line 162 def compatible_types [Type[:blob]] end |
#cql_aliases ⇒ Array<Symbol>
Returns other names used in CQL for this type.
124 125 126 |
# File 'lib/cequel/type.rb', line 124 def cql_aliases [] end |
#cql_name ⇒ Object
Returns the name of the type used in CQL. This is also the name that is used in all of Cequel’s public interfaces.
117 118 119 |
# File 'lib/cequel/type.rb', line 117 def cql_name self.class.name.demodulize.underscore.to_sym end |
#internal_name ⇒ Array<String>
use #internal_names
Returns full class name of this type used in Cassandra’s underlying representation.
134 135 136 |
# File 'lib/cequel/type.rb', line 134 def internal_name internal_names.first end |
#internal_names ⇒ Array<String>
Returns full class name(s) of this type used in Cassandra’s underlying representation (allows for multiple values for types that have different names between different versions).
143 144 145 |
# File 'lib/cequel/type.rb', line 143 def internal_names ["org.apache.cassandra.db.marshal.#{self.class.name.demodulize}Type"] end |
#to_s ⇒ Object
A string representation of this type
169 170 171 |
# File 'lib/cequel/type.rb', line 169 def to_s cql_name.to_s end |