Class: Sqlbuilder::Statements::Delete

Inherits:
Object
  • Object
show all
Includes:
Builders::DeleteBuilder
Defined in:
lib/sqlbuilder/statements/delete.rb

Instance Method Summary collapse

Methods included from Builders::SelectBuilder

#build_columns, #build_from, #build_joins, #build_limit, #build_offset, #build_order, #build_where

Constructor Details

#initialize(utils) ⇒ Delete

Returns a new instance of Delete.



8
9
10
# File 'lib/sqlbuilder/statements/delete.rb', line 8

def initialize(utils)
  @utils = utils
end

Instance Method Details

#buildObject



24
25
26
27
28
29
30
31
# File 'lib/sqlbuilder/statements/delete.rb', line 24

def build
  sql = "DELETE"

  sql << " #{build_from}"
  sql << " #{build_where}" if @where && !@where.empty?

  sql
end

#from(table) ⇒ Object



12
13
14
15
16
# File 'lib/sqlbuilder/statements/delete.rb', line 12

def from(table)
  @table = table

  self
end

#where(where) ⇒ Object



18
19
20
21
22
# File 'lib/sqlbuilder/statements/delete.rb', line 18

def where(where)
  @where = where

  self
end