Class: Cequel::Metal::Writer Abstract Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cequel/metal/writer.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.

This class is abstract.

Subclasses must implement #write_to_statement, which writes internal state to a Statement instance

Internal representation of a data manipulation statement

Since:

  • 1.0.0

Direct Known Subclasses

Deleter, Incrementer, Inserter, Updater

Instance Method Summary collapse

Constructor Details

#initialize(data_set, options = {}, &block) ⇒ Writer

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 a new instance of Writer.

Parameters:

  • data_set (DataSet)

    data set to write to

  • options (Options) (defaults to: {})

    options

Options Hash (options):

  • :ttl (Integer)

    time-to-live in seconds for the written data

  • :timestamp (Time, Integer)

    the timestamp associated with the column values

Since:

  • 1.0.0



23
24
25
26
27
# File 'lib/cequel/metal/writer.rb', line 23

def initialize(data_set, options = {}, &block)
  @data_set, @options, @block = data_set, options, block
  @statements, @bind_vars = [], []
  SimpleDelegator.new(self).instance_eval(&block) if block
end

Instance Method Details

#executevoid

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.

Execute the statement as a write operation

Since:

  • 1.0.0



34
35
36
37
38
39
40
# File 'lib/cequel/metal/writer.rb', line 34

def execute
  return if empty?
  statement = Statement.new
  write_to_statement(statement)
  statement.append(*data_set.row_specifications_cql)
  data_set.write(*statement.args)
end