Sha256: d021495aa51f067e5d8fd623ea4e50e3d973e2ebe1736ba5bf43f0ae0c502568

Contents?: true

Size: 843 Bytes

Versions: 5

Compression:

Stored size: 843 Bytes

Contents

module Arel
  ###
  # FIXME hopefully we can remove this
  module Crud
    # FIXME: this method should go away
    def update values
      um = UpdateManager.new @engine

      if Nodes::SqlLiteral === values
        relation = @ctx.froms
      else
        relation = values.first.first.relation
      end
      um.table relation
      um.set values
      um.take @ast.limit
      um.order(*@ast.orders)
      um.wheres = @ctx.wheres

      @engine.connection.update um.to_sql, 'AREL'
    end

    # FIXME: this method should go away
    def insert values
      im = InsertManager.new @engine
      im.insert values
      @engine.connection.insert im.to_sql
    end

    def delete
      dm = DeleteManager.new @engine
      dm.wheres = @ctx.wheres
      dm.from @ctx.froms
      @engine.connection.delete dm.to_sql, 'AREL'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
arel-2.0.6 lib/arel/crud.rb
arel-2.0.5 lib/arel/crud.rb
arel-2.0.4 lib/arel/crud.rb
arel-2.0.3 lib/arel/crud.rb
arel-2.0.2 lib/arel/crud.rb