Class: Riddle::Query::Delete

Inherits:
Object
  • Object
show all
Defined in:
lib/riddle/query/delete.rb

Instance Method Summary collapse

Constructor Details

#initialize(index, *ids) ⇒ Delete


2
3
4
5
# File 'lib/riddle/query/delete.rb', line 2

def initialize(index, *ids)
  @index = index
  @ids   = ids.flatten
end

Instance Method Details

#to_sqlObject


7
8
9
10
11
12
13
# File 'lib/riddle/query/delete.rb', line 7

def to_sql
  if @ids.length > 1
    "DELETE FROM #{@index} WHERE id IN (#{@ids.join(', ')})"
  else
    "DELETE FROM #{@index} WHERE id = #{@ids.first}"
  end
end