Class: Believer::Delete

Inherits:
FilterCommand show all
Defined in:
lib/believer/delete.rb

Overview

Creates CQL DELETE statements

Instance Attribute Summary

Attributes inherited from Command

#consistency_level, #record_class

Instance Method Summary collapse

Methods inherited from FilterCommand

#query_attributes, #where, #wheres, #wheres=

Methods inherited from Command

#can_execute?, #clone, #command_name, #consistency, #execute, #execution_options, #execution_options=, #initialize, #override_execution_options, #query_attributes

Constructor Details

This class inherits a constructor from Believer::Command

Instance Method Details

#to_cqlObject

Creates the CQL



6
7
8
9
10
# File 'lib/believer/delete.rb', line 6

def to_cql
  cql = "DELETE FROM #{record_class.table_name}"
  cql << " WHERE #{wheres.map { |wc| "#{wc.to_cql}" }.join(' AND ')}" if wheres.any?
  cql
end