Class: DB::Context::Transaction

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

Instance Method Summary collapse

Methods inherited from Session

#call

Methods inherited from Generic

#call, #clause, #close, #connection, #connection?, #initialize, #query

Constructor Details

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

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