123456789_123456789_123456789_123456789_123456789_

Class: Arel::UpdateManager

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, TreeManager
Instance Chain:
Inherits: Arel::TreeManager
Defined in: activerecord/lib/arel/update_manager.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(table = nil) ⇒ UpdateManager

[ GitHub ]

  
# File 'activerecord/lib/arel/update_manager.rb', line 7

def initialize(table = nil)
  @ast = Nodes::UpdateStatement.new(table)
end

Instance Method Details

#group(columns)

[ GitHub ]

  
# File 'activerecord/lib/arel/update_manager.rb', line 33

def group(columns)
  columns.each do |column|
    column = Nodes::SqlLiteral.new(column) if String === column
    column = Nodes::SqlLiteral.new(column.to_s) if Symbol === column

    @ast.groups.push Nodes::Group.new column
  end

  self
end

#having(expr)

[ GitHub ]

  
# File 'activerecord/lib/arel/update_manager.rb', line 44

def having(expr)
  @ast.havings << expr
  self
end

#set(values)

[ GitHub ]

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

def set(values)
  case values
  when String, Nodes::BoundSqlLiteral
    @ast.values = [values]
  else
    @ast.values = values.map { |column, value|
      Nodes::Assignment.new(
        Nodes::UnqualifiedColumn.new(column),
        value
      )
    }
  end
  self
end

#table(table)

UPDATE table

[ GitHub ]

  
# File 'activerecord/lib/arel/update_manager.rb', line 13

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