Class: Arel::UpdateManager

Inherits:
TreeManager show all
Defined in:
lib/arel/update_manager.rb

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, #visitor

Methods included from FactoryMethods

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

Constructor Details

- (UpdateManager) initialize(engine)



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

- (Object) key



18
19
20
# File 'lib/arel/update_manager.rb', line 18

def key
  @ast.key
end

- (Object) key=(key)



14
15
16
# File 'lib/arel/update_manager.rb', line 14

def key= key
  @ast.key = Nodes.build_quoted(key)
end

- (Object) order(*expr)



22
23
24
25
# File 'lib/arel/update_manager.rb', line 22

def order *expr
  @ast.orders = expr
  self
end

- (Object) set(values)



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/arel/update_manager.rb', line 43

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

- (Object) table(table)

UPDATE table



29
30
31
32
# File 'lib/arel/update_manager.rb', line 29

def table table
  @ast.relation = table
  self
end

- (Object) take(limit)



9
10
11
12
# File 'lib/arel/update_manager.rb', line 9

def take limit
  @ast.limit = Nodes::Limit.new(Nodes.build_quoted(limit)) if limit
  self
end

- (Object) where(expr)



38
39
40
41
# File 'lib/arel/update_manager.rb', line 38

def where expr
  @ast.wheres << expr
  self
end

- (Object) wheres=(exprs)



34
35
36
# File 'lib/arel/update_manager.rb', line 34

def wheres= exprs
  @ast.wheres = exprs
end