class Arel::InsertManager - arel-4.0.2 Documentation

# class Arel::InsertManager

### Public Class Methods

new(engine) click to toggle source
Calls superclass method Arel::TreeManager.new

    # File lib/arel/insert_manager.rb, line 3
    def initialize engine
      super
      @ast = Nodes::InsertStatement.new
    end

### Public Instance Methods

columns() click to toggle source

    # File lib/arel/insert_manager.rb, line 13
    def columns; @ast.columns end

create_values(values, columns) click to toggle source

    # File lib/arel/insert_manager.rb, line 34
    def create_values values, columns
      Nodes::Values.new values, columns
    end

insert(fields) click to toggle source

    # File lib/arel/insert_manager.rb, line 16
    def insert fields
      return if fields.empty?

      if String === fields
        @ast.values = SqlLiteral.new(fields)
      else
        @ast.relation ||= fields.first.first.relation

        values = []

        fields.each do |column, value|
          @ast.columns << column
          values << value
        end
        @ast.values = create_values values, @ast.columns
      end
    end

into(table) click to toggle source

    # File lib/arel/insert_manager.rb, line 8
    def into table
      @ast.relation = table
      self
    end

values=(val;) click to toggle source

    # File lib/arel/insert_manager.rb, line 14
    def values= val; @ast.values = val; end