Class: Arel::DeleteManager

Inherits:
TreeManager show all
Includes:
TreeManager::StatementMethods
Defined in:
lib/arel/delete_manager.rb

Instance Attribute Summary

Attributes inherited from TreeManager

#ast

Instance Method Summary collapse

Methods included from TreeManager::StatementMethods

#key, #key=, #offset, #order, #take, #where, #wheres=

Methods inherited from TreeManager

#initialize_copy, #to_dot, #to_sql

Methods included from FactoryMethods

#coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower

Constructor Details

#initialize(table = nil) ⇒ DeleteManager

Returns a new instance of DeleteManager.



7
8
9
# File 'lib/arel/delete_manager.rb', line 7

def initialize(table = nil)
  @ast = Nodes::DeleteStatement.new(table)
end

Instance Method Details

#from(relation) ⇒ Object



11
12
13
14
# File 'lib/arel/delete_manager.rb', line 11

def from(relation)
  @ast.relation = relation
  self
end

#group(columns) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/arel/delete_manager.rb', line 16

def group(columns)
  columns.each do |column|
    column = Nodes::SqlLiteral.new(column) if String === column
    column = Nodes::SqlLiteral.new(column.to_s) if Symbol === column

    @ast.groups.push Nodes::Group.new column
  end

  self
end

#having(expr) ⇒ Object



27
28
29
30
# File 'lib/arel/delete_manager.rb', line 27

def having(expr)
  @ast.havings << expr
  self
end