Class: Cequel::Metal::Statement Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cequel/metal/statement.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Builder for CQL statements. Contains a CQL string with bind substitutions and a collection of bind variables

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatement

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Statement.

Since:

  • 1.0.0



14
15
16
# File 'lib/cequel/metal/statement.rb', line 14

def initialize
  @cql, @bind_vars = [], []
end

Instance Attribute Details

#bind_varsArray (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns bind variables for CQL string.

Returns:

  • (Array)

    bind variables for CQL string

Since:

  • 1.0.0



12
13
14
# File 'lib/cequel/metal/statement.rb', line 12

def bind_vars
  @bind_vars
end

Instance Method Details

#append(cql, *bind_vars) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Add a CQL fragment with optional bind variables to the end of the statement

Parameters:

  • cql (String)

    CQL fragment

  • bind_vars (Object)

    zero or more bind variables

Since:

  • 1.0.0



45
46
47
48
49
# File 'lib/cequel/metal/statement.rb', line 45

def append(cql, *bind_vars)
  @cql << cql
  @bind_vars.concat(bind_vars)
  self
end

#argsArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns this statement as an array of arguments to Keyspace#execute (CQL string followed by bind variables).

Returns:

  • (Array)

    this statement as an array of arguments to Keyspace#execute (CQL string followed by bind variables)

Since:

  • 1.0.0



55
56
57
# File 'lib/cequel/metal/statement.rb', line 55

def args
  [cql, *bind_vars]
end

#cqlString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns CQL statement.

Returns:

  • (String)

    CQL statement

Since:

  • 1.0.0



21
22
23
# File 'lib/cequel/metal/statement.rb', line 21

def cql
  @cql.join
end

#prepend(cql, *bind_vars) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Add a CQL fragment with optional bind variables to the beginning of the statement

Parameters:

  • cql (String)

    CQL fragment

  • bind_vars (Object)

    zero or more bind variables

Since:

  • 1.0.0



32
33
34
35
# File 'lib/cequel/metal/statement.rb', line 32

def prepend(cql, *bind_vars)
  @cql.unshift(cql)
  @bind_vars.unshift(*bind_vars)
end