Class: Cequel::Metal::Deleter

Inherits:
Writer
  • Object
show all
Defined in:
lib/cequel/metal/deleter.rb

Overview

Note:

This class should not be instantiated directly

DSL for the construction of a DELETE statement comprising multiple operations (e.g. deleting a column value, deleting an element from a list, etc.)

Instance Attribute Summary

Attributes inherited from Writer

#type_hints

Instance Method Summary collapse

Methods inherited from Writer

#execute, #initialize

Methods included from Util::Forwardable

#delegate

Constructor Details

This class inherits a constructor from Cequel::Metal::Writer

Instance Method Details

#delete_columns(*columns) ⇒ void

This method returns an undefined value.

Delete specified columns

Parameters:

  • columns (Symbol)

    column names to delete

Since:

  • 1.0.0


33
34
35
# File 'lib/cequel/metal/deleter.rb', line 33

def delete_columns(*columns)
  statements.concat(columns)
end

#delete_rowvoid

This method returns an undefined value.

Delete the entire row or rows matched by the data set

Since:

  • 1.0.0


23
24
25
# File 'lib/cequel/metal/deleter.rb', line 23

def delete_row
  @delete_row = true
end

#list_remove_at(column, *positions) ⇒ void

This method returns an undefined value.

Remove elements from a list by position

Parameters:

  • column (Symbol)

    name of list column

  • positions (Integer)

    positions in list from which to delete elements

Since:

  • 1.0.0


45
46
47
48
# File 'lib/cequel/metal/deleter.rb', line 45

def list_remove_at(column, *positions)
  statements
    .concat(positions.map { |position| "#{column}[#{position}]" })
end

#map_remove(column, *keys) ⇒ void

This method returns an undefined value.

Remote elements from a map by key

Parameters:

  • column (Symbol)

    name of map column

  • keys (Object)

    keys to delete from map

Since:

  • 1.0.0


57
58
59
60
# File 'lib/cequel/metal/deleter.rb', line 57

def map_remove(column, *keys)
  statements.concat(keys.length.times.map { "#{column}[?]" })
  bind_vars.concat(keys)
end