Class: DB::Context::Transaction

Inherits:
Session
  • Object
show all
Defined in:
lib/db/context/transaction.rb

Instance Attribute Summary

Attributes inherited from Session

#connection

Instance Method Summary collapse

Methods inherited from Session

#call, #clause, #close, #flush, #initialize, #next_result, #query, #results, #send_query

Constructor Details

This class inherits a constructor from DB::Context::Session

Instance Method Details

#abortObject

Abort the transaction and return the connection to the connection pool.


35
36
37
38
# File 'lib/db/context/transaction.rb', line 35

def abort
	self.call("ROLLBACK")
	self.close
end

#commitObject

Commit the transaction and return the connection to the connection pool.


29
30
31
32
# File 'lib/db/context/transaction.rb', line 29

def commit
	self.call("COMMIT")
	self.close
end

#rollback(name) ⇒ Object

Return back to a previously registered savepoint.


46
47
48
# File 'lib/db/context/transaction.rb', line 46

def rollback(name)
	self.call("ROLLBACK #{name}")
end

#savepoint(name) ⇒ Object

Mark a savepoint in the transaction.


41
42
43
# File 'lib/db/context/transaction.rb', line 41

def savepoint(name)
	self.call("SAVEPOINT #{name}")
end