Class: Cassandra::Statements::Batch
- Inherits:
-
Object
- Object
- Cassandra::Statements::Batch
- Includes:
- Cassandra::Statement
- Defined in:
- lib/cassandra/statements/batch.rb
Overview
Batch statement groups several Cassandra::Statement. There are several types of Batch statements available:
Instance Method Summary collapse
-
#add(statement, args = nil, type_hints = nil) ⇒ self
Adds a statement to this batch.
-
#cql ⇒ nil
A batch statement doesn't really have any cql of its own as it is composed of multiple different statements.
-
#inspect ⇒ String
A CLI-friendly batch statement representation.
-
#type ⇒ Symbol
One of
:logged
,:unlogged
or:counter
.
Instance Method Details
#add(statement, args = nil, type_hints = nil) ⇒ self
Positional arguments for simple statements are only supported starting with Apache Cassandra 2.0 and above.
Named arguments for simple statements are only supported starting with Apache Cassandra 2.1 and above.
Adds a statement to this batch.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/cassandra/statements/batch.rb', line 76 def add(statement, args = nil, type_hints = nil) args ||= EMPTY_LIST type_hints ||= EMPTY_LIST case statement when String @statements << Simple.new(statement, args, type_hints) when Prepared @statements << statement.bind(args) when Bound, Simple @statements << statement else raise ::ArgumentError, "a batch can only consist of simple or prepared statements, #{statement.inspect} given" end self end |
#cql ⇒ nil
A batch statement doesn't really have any cql of its own as it is composed of multiple different statements
96 97 98 |
# File 'lib/cassandra/statements/batch.rb', line 96 def cql nil end |
#inspect ⇒ String
Returns a CLI-friendly batch statement representation.
105 106 107 |
# File 'lib/cassandra/statements/batch.rb', line 105 def inspect "#<#{self.class.name}:0x#{self.object_id.to_s(16)} @type=#{type.inspect}>" end |
#type ⇒ Symbol
Returns one of :logged
, :unlogged
or :counter
.
101 102 |
# File 'lib/cassandra/statements/batch.rb', line 101 def type end |