Class: Cequel::Metal::Inserter
- Defined in:
- lib/cequel/metal/inserter.rb
Overview
Encapsulates an ‘INSERT` statement
Instance Method Summary collapse
-
#execute(options = {}) ⇒ void
Execute the statement as a write operation.
-
#initialize(data_set) ⇒ Inserter
constructor
A new instance of Inserter.
-
#insert(data) ⇒ void
Insert the given data into the table.
Constructor Details
#initialize(data_set) ⇒ Inserter
Returns a new instance of Inserter.
14 15 16 17 |
# File 'lib/cequel/metal/inserter.rb', line 14 def initialize(data_set) @row = {} super end |
Instance Method Details
#execute(options = {}) ⇒ void
This method returns an undefined value.
Execute the statement as a write operation
22 23 24 25 26 27 28 |
# File 'lib/cequel/metal/inserter.rb', line 22 def execute( = {}) statement = Statement.new consistency = .fetch(:consistency, data_set.query_consistency) write_to_statement(statement, ) data_set.write_with_consistency( statement.cql, statement.bind_vars, consistency) end |
#insert(data) ⇒ void
This method returns an undefined value.
Insert the given data into the table
36 37 38 |
# File 'lib/cequel/metal/inserter.rb', line 36 def insert(data) @row.merge!(data.symbolize_keys) end |