Class: Arel::UpdateManager
Instance Attribute Summary
Attributes inherited from TreeManager
#ast, #bind_values, #engine
Instance Method Summary
collapse
Methods inherited from TreeManager
#initialize_copy, #to_dot, #to_sql
#create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower
Constructor Details
Returns a new instance of UpdateManager.
4
5
6
7
8
|
# File 'lib/arel/update_manager.rb', line 4
def initialize
super
@ast = Nodes::UpdateStatement.new
@ctx = @ast
end
|
Instance Method Details
#key ⇒ Object
19
20
21
|
# File 'lib/arel/update_manager.rb', line 19
def key
@ast.key
end
|
#key=(key) ⇒ Object
15
16
17
|
# File 'lib/arel/update_manager.rb', line 15
def key= key
@ast.key = Nodes.build_quoted(key)
end
|
#order(*expr) ⇒ Object
23
24
25
26
|
# File 'lib/arel/update_manager.rb', line 23
def order *expr
@ast.orders = expr
self
end
|
#set(values) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/arel/update_manager.rb', line 44
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
30
31
32
33
|
# File 'lib/arel/update_manager.rb', line 30
def table table
@ast.relation = table
self
end
|
#take(limit) ⇒ Object
10
11
12
13
|
# File 'lib/arel/update_manager.rb', line 10
def take limit
@ast.limit = Nodes::Limit.new(Nodes.build_quoted(limit)) if limit
self
end
|
#where(expr) ⇒ Object
39
40
41
42
|
# File 'lib/arel/update_manager.rb', line 39
def where expr
@ast.wheres << expr
self
end
|
#wheres=(exprs) ⇒ Object
35
36
37
|
# File 'lib/arel/update_manager.rb', line 35
def wheres= exprs
@ast.wheres = exprs
end
|