Module: Arel::Crud

Included in:
SelectManager, Table
Defined in:
lib/arel/crud.rb

Overview

FIXME hopefully we can remove this

Instance Method Summary collapse

Instance Method Details

#deleteObject



30
31
32
33
34
35
# File 'lib/arel/crud.rb', line 30

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

#insert(values) ⇒ Object

FIXME: this method should go away



24
25
26
27
28
# File 'lib/arel/crud.rb', line 24

def insert values
  im = InsertManager.new @engine
  im.insert values
  @engine.connection.insert im.to_sql
end

#update(values) ⇒ Object

FIXME: this method should go away



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/arel/crud.rb', line 6

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.expr if @ast.limit
  um.order(*@ast.orders)
  um.wheres = @ctx.wheres

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