Module: DbAgile::SequelAdapter::Data::TransactionDriven

Included in:
DbAgile::SequelAdapter
Defined in:
lib/dbagile/adapter/sequel/data/transaction_driven.rb

Instance Method Summary collapse

Instance Method Details

#delete(transaction, table_name, proj = {}) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/dbagile/adapter/sequel/data/transaction_driven.rb', line 23

def delete(transaction, table_name, proj = {})
  if proj.empty?
    db[table_name].delete
  else
    db[table_name].where(proj).delete
  end
  true
end

#direct_sql(transaction, sql) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/dbagile/adapter/sequel/data/transaction_driven.rb', line 33

def direct_sql(transaction, sql)
  if /^\s*(select|SELECT)/ =~ sql
    dataset(sql)
  else
    db << sql
  end
end

#insert(transaction, table, tuple) ⇒ Object



7
8
9
10
# File 'lib/dbagile/adapter/sequel/data/transaction_driven.rb', line 7

def insert(transaction, table, tuple)
  db[table].insert(tuple)
  tuple
end

#update(transaction, table_name, update, proj = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/dbagile/adapter/sequel/data/transaction_driven.rb', line 13

def update(transaction, table_name, update, proj = {})
  if proj.nil? or proj.empty?
    db[table_name].update(update)
  else
    db[table_name].where(proj).update(update)
  end 
  update
end