Sha256: 32a5da61f7dfd4260524f67198c1cf8fa8e892eac55625eb4dc79088ea45a5be

Contents?: true

Size: 630 Bytes

Versions: 2

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true

module Arel # :nodoc: all
  class UpdateManager < Arel::TreeManager
    include TreeManager::StatementMethods

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

    ###
    # UPDATE +table+
    def table(table)
      @ast.relation = table
      self
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-7.0.0.alpha2 lib/arel/update_manager.rb
activerecord-7.0.0.alpha1 lib/arel/update_manager.rb