Class: DB::Context::Transaction

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

Instance Method Summary collapse

Methods inherited from Session

#call, #clause, #close, #closed?, #connection, #connection?, #initialize, #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.



24
25
26
27
# File 'lib/db/context/transaction.rb', line 24

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

#commitObject

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



12
13
14
15
# File 'lib/db/context/transaction.rb', line 12

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

#commit?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/db/context/transaction.rb', line 17

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

#rollback(name) ⇒ Object

Return back to a previously registered savepoint.



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

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

#savepoint(name) ⇒ Object

Mark a savepoint in the transaction.



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

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