class Cequel::Type::Base

The base class for all type objects. Types are singletons.

@abstract 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

Public Instance Methods

cast(value) click to toggle source

@param value the value to cast @return the value cast to the correct Ruby class for this type

# File lib/cequel/type.rb, line 157
def cast(value)
  value
end
compatible_types() click to toggle source

CQL only allows changing column types when the old type's binary representation is compatible with the new type.

@return [Array<Type>] new types that columns of this type may be

altered to
# File lib/cequel/type.rb, line 168
def compatible_types
  [Type[:blob]]
end
cql_aliases() click to toggle source

@return [Array<Symbol>] other names used in CQL for this type

# File lib/cequel/type.rb, line 130
def cql_aliases
  []
end
cql_name() click to toggle source

@return the name of the type used in CQL. This is also the name that is

used in all of Cequel's public interfaces
# File lib/cequel/type.rb, line 123
def cql_name
  self.class.name.demodulize.underscore.to_sym
end
internal_name() click to toggle source

@return [Array<String>] full class name of this type used in

Cassandra's underlying representation

@deprecated use {internal_names}

# File lib/cequel/type.rb, line 140
def internal_name
  internal_names.first
end
internal_names() click to toggle source

@return [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)
# File lib/cequel/type.rb, line 149
def internal_names
  ["org.apache.cassandra.db.marshal.#{self.class.name.demodulize}Type"]
end
to_s() click to toggle source

A string representation of this type

# File lib/cequel/type.rb, line 175
def to_s
  cql_name.to_s
end