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
#create_and, #create_join, #create_on, #create_string_join, #create_table_alias, #grouping, #lower
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
#key=(key) ⇒ Object
14
15
16
|
# File 'lib/arel/update_manager.rb', line 14
def key= key
@ast.key = key
end
|
#order(*expr) ⇒ Object
18
19
20
21
|
# File 'lib/arel/update_manager.rb', line 18
def order *expr
@ast.orders = expr
self
end
|
#set(values) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/arel/update_manager.rb', line 39
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
25
26
27
28
|
# File 'lib/arel/update_manager.rb', line 25
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
34
35
36
37
|
# File 'lib/arel/update_manager.rb', line 34
def where expr
@ast.wheres << expr
self
end
|
#wheres=(exprs) ⇒ Object
30
31
32
|
# File 'lib/arel/update_manager.rb', line 30
def wheres= exprs
@ast.wheres = exprs
end
|