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