class Cql::Model::Query::Statement

Public Class Methods

new(klass, client) click to toggle source

Initialize instance variables common to all statements

@param [Class] klass Model class @param [Cql::Client] client used to connect to Cassandra

# File lib/cql/model/query/statement.rb, line 9
def initialize(klass, client)
  @klass       = klass
  @client      = client || klass.cql_client
  @consistency = nil
end

Public Instance Methods

consistency(consist) click to toggle source

Specify consistency level to use when executing statemnt See www.datastax.com/docs/1.0/dml/data_consistency Defaults to :local_quorum

@param [String] consistency One of ‘ANY’, ‘ONE’, ‘QUORUM’, ‘LOCAL_QUORUM’, ‘EACH_QUORUM’, ‘ALL’ as of Cassandra 1.0 @return [String] consistency value

# File lib/cql/model/query/statement.rb, line 35
def consistency(consist)
  raise ArgumentError, "Cannot specify USING CONSISTENCY twice" unless @consistency.nil?
  @consistency = consist
  self
end
Also aliased as: using_consistency
execute() click to toggle source

Execute this CQL statement. Return value and parameters vary for each derived class. @see SelectStatement#execute @see InsertStatement#execute @see UpdateStatement#execute

# File lib/cql/model/query/statement.rb, line 25
def execute
  raise NotImplementedError, "Subclass responsibility"
end
to_s() click to toggle source

Build a string representation of this CQL statement, suitable for execution by a CQL client. @return [String]

# File lib/cql/model/query/statement.rb, line 17
def to_s
  raise NotImplementedError, "Subclass responsibility"
end
using_consistency(consist)
Alias for: consistency