class Cequel::Schema::Column
Represents a column definition in a table schema.
@abstract
Attributes
@return [Symbol] the name of the column
@return [Type] the type of the column
Public Class Methods
@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
@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
@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
@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
@return [Boolean] true if this is a collection column
# File lib/cequel/schema/column.rb, line 69 def collection_column? false end
@return [Boolean] true if this is a data column
# File lib/cequel/schema/column.rb, line 62 def data_column? !key? end
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
@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
@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
@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
@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
@return [String] the column's name
# File lib/cequel/schema/column.rb, line 123 def to_s name.to_s end
@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