Class: Cql::Model::Query::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/cql/model/query/statement.rb

Direct Known Subclasses

MutationStatement, SelectStatement

Instance Method Summary collapse

Constructor Details

#initialize(klass, client) ⇒ Statement

Initialize instance variables common to all statements

Parameters:

  • klass (Class)

    Model class

  • client (Cql::Client)

    used to connect to Cassandra



9
10
11
12
13
# File 'lib/cql/model/query/statement.rb', line 9

def initialize(klass, client)
  @klass       = klass
  @client      = client || klass.cql_client
  @consistency = nil
end

Instance Method Details

#consistency(consist) ⇒ String Also known as: using_consistency

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

Parameters:

  • consistency (String)

    One of ‘ANY’, ‘ONE’, ‘QUORUM’, ‘LOCAL_QUORUM’, ‘EACH_QUORUM’, ‘ALL’ as of Cassandra 1.0

Returns:

  • (String)

    consistency value

Raises:

  • (ArgumentError)


35
36
37
38
39
# 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

#executeObject

Execute this CQL statement. Return value and parameters vary for each derived class.



25
26
27
# File 'lib/cql/model/query/statement.rb', line 25

def execute
  raise NotImplementedError, "Subclass responsibility"
end

#to_sString

Build a string representation of this CQL statement, suitable for execution by a CQL client.

Returns:

  • (String)

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/cql/model/query/statement.rb', line 17

def to_s
  raise NotImplementedError, "Subclass responsibility"
end