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, #closed?, #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.



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

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

#commit?Boolean

Returns:

  • (Boolean)


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

def commit?
	unless self.closed?
		self.commit
	end
end

#rollback(name) ⇒ Object

Return back to a previously registered savepoint.



52
53
54
# File 'lib/db/context/transaction.rb', line 52

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

#savepoint(name) ⇒ Object

Mark a savepoint in the transaction.



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

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