Class: Arel::UpdateManager
Instance Attribute Summary
Attributes inherited from TreeManager
#ast, #engine, #visitor
Instance Method Summary
collapse
Methods inherited from TreeManager
#initialize_copy, #to_dot, #to_sql
Constructor Details
Returns a new instance of UpdateManager.
3
4
5
6
7
|
# File 'lib/arel/update_manager.rb', line 3
def initialize engine
super
@ast = Nodes::UpdateStatement.new
@ctx = @ast
end
|
Instance Method Details
#order(*expr) ⇒ Object
14
15
16
17
|
# File 'lib/arel/update_manager.rb', line 14
def order *expr
@ast.orders = expr
self
end
|
#set(values) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/arel/update_manager.rb', line 35
def set values
if String === values
@ast.values = [values]
else
@ast.values = values.map { |column,value|
Nodes::Assignment.new(
Nodes::UnqualifiedColumn.new(column),
value
)
}
end
self
end
|
#table(table) ⇒ Object
21
22
23
24
|
# File 'lib/arel/update_manager.rb', line 21
def table table
@ast.relation = table
self
end
|
#take(limit) ⇒ Object
9
10
11
12
|
# File 'lib/arel/update_manager.rb', line 9
def take limit
@ast.limit = Nodes::Limit.new(limit) if limit
self
end
|
#where(expr) ⇒ Object
30
31
32
33
|
# File 'lib/arel/update_manager.rb', line 30
def where expr
@ast.wheres << expr
self
end
|
#wheres=(exprs) ⇒ Object
26
27
28
|
# File 'lib/arel/update_manager.rb', line 26
def wheres= exprs
@ast.wheres = exprs
end
|