class Cequel::Schema::Column

Represents a column definition in a table schema.

@abstract

Attributes

name[R]

@return [Symbol] the name of the column

type[R]

@return [Type] the type of the column

Public Class Methods

new(name, type) click to toggle source

@param name [Symbol] the name of the column @param type [Type] the type of the column

# File lib/cequel/schema/column.rb, line 18
def initialize(name, type)
  @name, @type = name, type
end

Public Instance Methods

==(other) click to toggle source

@param other [Column] a column object @return [Boolean] true if this column has the same CQL representation

as `other` column
# File lib/cequel/schema/column.rb, line 115
def ==(other)
  to_cql == other.to_cql
end
Also aliased as: eql?
cast(value) click to toggle source

@param value the value to cast @return the value cast to the appropriate type for this column

@api private

# File lib/cequel/schema/column.rb, line 96
def cast(value)
  @type.cast(value)
end
clustering_column?() click to toggle source

@return [Boolean] true if this is a clustering column

@see

http://cassandra.apache.org/doc/cql3/CQL.html#createTablepartitionClustering
CQL3 key documentation
# File lib/cequel/schema/column.rb, line 53
def clustering_column?
  false
end
collection_column?() click to toggle source

@return [Boolean] true if this is a collection column

# File lib/cequel/schema/column.rb, line 69
def collection_column?
  false
end
data_column?() click to toggle source

@return [Boolean] true if this is a data column

# File lib/cequel/schema/column.rb, line 62
def data_column?
  !key?
end
eql?(other)
Alias for: ==
indexed?() click to toggle source

Indicates if this column is indexed. Overridden by subclasses that support indexing.

@return [Boolean] true if this column has a secondary index

# File lib/cequel/schema/column.rb, line 78
def indexed?
  false
end
inspect() click to toggle source

@return [String] human-readable representation of this column

# File lib/cequel/schema/column.rb, line 130
def inspect
  %Q(#<#{self.class.name}: #{to_cql}>)
end
key?() click to toggle source

@return [Boolean] true if this is a key column

@see

http://cassandra.apache.org/doc/cql3/CQL.html#createTablepartitionClustering
CQL3 key documentation
# File lib/cequel/schema/column.rb, line 31
def key?
  partition_key? || clustering_column?
end
partition_key?() click to toggle source

@return [Boolean] true if this is a partition key column

@see

http://cassandra.apache.org/doc/cql3/CQL.html#createTablepartitionClustering
CQL3 key documentation
# File lib/cequel/schema/column.rb, line 42
def partition_key?
  false
end
to_cql() click to toggle source

@return [String] a CQL fragment representing this column in a table

definition

@api private

# File lib/cequel/schema/column.rb, line 106
def to_cql
  %Q|"#{@name}" #{@type}|
end
to_s() click to toggle source

@return [String] the column's name

# File lib/cequel/schema/column.rb, line 123
def to_s
  name.to_s
end
type?(type_in) click to toggle source

@param type_in [Symbol,Type] type to check against @return [Boolean] true if this column has the type given by `type_in`

# File lib/cequel/schema/column.rb, line 86
def type?(type_in)
  type == Type[type_in]
end