Module: Arel::Crud

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

Overview

FIXME hopefully we can remove this

Instance Method Summary collapse

Instance Method Details

#compile_delete(key = nil, having_clause = nil, group_values_columns = []) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/arel/crud.rb', line 36

def compile_delete(key = nil, having_clause = nil, group_values_columns = [])
  dm = DeleteManager.new(source)
  dm.take(limit)
  dm.offset(offset)
  dm.order(*orders)
  dm.wheres = constraints
  dm.key = key
  dm.group(group_values_columns) unless group_values_columns.empty?
  dm.having(having_clause) unless having_clause.nil?
  dm
end

#compile_insert(values) ⇒ Object



7
8
9
10
11
# File 'lib/arel/crud.rb', line 7

def compile_insert(values)
  im = create_insert
  im.insert values
  im
end

#compile_update(values, key = nil, having_clause = nil, group_values_columns = []) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/arel/crud.rb', line 17

def compile_update(
  values,
  key = nil,
  having_clause = nil,
  group_values_columns = []
)
  um = UpdateManager.new(source)
  um.set(values)
  um.take(limit)
  um.offset(offset)
  um.order(*orders)
  um.wheres = constraints
  um.key = key

  um.group(group_values_columns) unless group_values_columns.empty?
  um.having(having_clause) unless having_clause.nil?
  um
end

#create_insertObject



13
14
15
# File 'lib/arel/crud.rb', line 13

def create_insert
  InsertManager.new
end