Class: Cequel::Metal::Statement Private
- Inherits:
-
Object
- Object
- Cequel::Metal::Statement
- 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
Instance Attribute Summary collapse
-
#bind_vars ⇒ Array
readonly
private
Bind variables for CQL string.
Instance Method Summary collapse
-
#append(cql, *bind_vars) ⇒ void
private
Add a CQL fragment with optional bind variables to the end of the statement.
-
#args ⇒ Array
private
This statement as an array of arguments to Keyspace#execute (CQL string followed by bind variables).
-
#initialize(cql_or_prepared = '', bind_vars = []) ⇒ Array
constructor
private
Cassandra type hints for bind variables.
-
#prepare(keyspace) ⇒ Cassandra::Statements::Prepared
private
Prepared version of this statement.
-
#prepend(cql, *bind_vars) ⇒ void
private
Add a CQL fragment with optional bind variables to the beginning of the statement.
-
#to_s ⇒ String
(also: #cql)
private
CQL statement.
Constructor Details
#initialize(cql_or_prepared = '', bind_vars = []) ⇒ Array
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 cassandra type hints for bind variables.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cequel/metal/statement.rb', line 15 def initialize(cql_or_prepared='', bind_vars=[]) cql, prepared = *case cql_or_prepared when Cassandra::Statements::Prepared [cql_or_prepared.cql, cql_or_prepared] else [cql_or_prepared.to_s, nil] end @cql, @prepared, @bind_vars = cql, prepared, bind_vars end |
Instance Attribute Details
#bind_vars ⇒ Array (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.
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
59 60 61 62 63 64 65 |
# File 'lib/cequel/metal/statement.rb', line 59 def append(cql, *bind_vars) unless cql.nil? @cql << cql @bind_vars.concat(bind_vars) end self end |
#args ⇒ Array
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).
71 72 73 |
# File 'lib/cequel/metal/statement.rb', line 71 def args [cql, *bind_vars] end |
#prepare(keyspace) ⇒ Cassandra::Statements::Prepared
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 prepared version of this statement.
35 36 37 |
# File 'lib/cequel/metal/statement.rb', line 35 def prepare(keyspace) @prepared ||= keyspace.client.prepare(cql) 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
46 47 48 49 |
# File 'lib/cequel/metal/statement.rb', line 46 def prepend(cql, *bind_vars) @cql.prepend(cql) @bind_vars.unshift(*bind_vars) end |
#to_s ⇒ String Also known as: cql
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.
29 30 31 |
# File 'lib/cequel/metal/statement.rb', line 29 def to_s @cql end |