Class: Cequel::Metal::Inserter
- Defined in:
- lib/cequel/metal/inserter.rb
Overview
Encapsulates an ‘INSERT` statement
Instance Attribute Summary
Attributes inherited from Writer
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.
Methods included from Util::Forwardable
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 29 |
# 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.(statement, consistency: consistency ) end |
#insert(data) ⇒ void
This method returns an undefined value.
Insert the given data into the table
37 38 39 |
# File 'lib/cequel/metal/inserter.rb', line 37 def insert(data) @row.merge!(data.symbolize_keys) end |