Class: Riddle::Query::Delete
- Inherits:
-
Object
- Object
- Riddle::Query::Delete
- Defined in:
- lib/riddle/query/delete.rb
Instance Method Summary collapse
-
#initialize(index, *ids) ⇒ Delete
constructor
A new instance of Delete.
- #to_sql ⇒ Object
Constructor Details
#initialize(index, *ids) ⇒ Delete
Returns a new instance of Delete.
4 5 6 7 |
# File 'lib/riddle/query/delete.rb', line 4 def initialize(index, *ids) @index = index @ids = ids.flatten end |
Instance Method Details
#to_sql ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/riddle/query/delete.rb', line 9 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 |