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.
158 159 160 |
# File 'lib/cequel/type.rb', line 158 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.
169 170 171 |
# File 'lib/cequel/type.rb', line 169 def compatible_types [Type[:blob]] end |
#cql_aliases ⇒ Array<Symbol>
Returns other names used in CQL for this type.
131 132 133 |
# File 'lib/cequel/type.rb', line 131 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.
124 125 126 |
# File 'lib/cequel/type.rb', line 124 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.
141 142 143 |
# File 'lib/cequel/type.rb', line 141 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).
150 151 152 |
# File 'lib/cequel/type.rb', line 150 def internal_names ["org.apache.cassandra.db.marshal.#{self.class.name.demodulize}Type"] end |
#to_s ⇒ Object
A string representation of this type
176 177 178 |
# File 'lib/cequel/type.rb', line 176 def to_s cql_name.to_s end |