Class: Arel::UpdateManager

Inherits:
TreeManager show all
Includes:
TreeManager::StatementMethods
Defined in:
activerecord/lib/arel/update_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, #where

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

#initializeUpdateManager

Returns a new instance of UpdateManager.



7
8
9
10
11
# File 'activerecord/lib/arel/update_manager.rb', line 7

def initialize
  super
  @ast = Nodes::UpdateStatement.new
  @ctx = @ast
end

Instance Method Details

#set(values) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'activerecord/lib/arel/update_manager.rb', line 20

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

UPDATE table



15
16
17
18
# File 'activerecord/lib/arel/update_manager.rb', line 15

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