Class: Cequel::Metal::Writer Abstract Private

Inherits:
Object
  • Object
show all
Extended by:
Util::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 Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::Forwardable

delegate

Constructor Details

#initialize(data_set, &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

Since:

  • 1.0.0



21
22
23
24
25
# File 'lib/cequel/metal/writer.rb', line 21

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

Instance Attribute Details

#type_hintsObject

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.

Since:

  • 1.0.0



16
17
18
# File 'lib/cequel/metal/writer.rb', line 16

def type_hints
  @type_hints
end

Instance Method Details

#execute(options = {}) ⇒ void

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

Parameters:

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

    options

Options Hash (options):

  • :consistency (Symbol)

    what consistency level to use for the operation

  • :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



39
40
41
42
43
44
45
46
47
48
# File 'lib/cequel/metal/writer.rb', line 39

def execute(options = {})
  options.assert_valid_keys(:timestamp, :ttl, :consistency)
  return if empty?
  statement = Statement.new
  consistency = options.fetch(:consistency, data_set.query_consistency)
  write_to_statement(statement, options)
  statement.append(*data_set.row_specifications_cql)
  data_set.write_with_options(statement,
                              consistency: consistency)
end