Class: SBDB::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/sbdb/transaction.rb

Constant Summary collapse

NOSYNC =
Bdb::DB_TXN_NOSYNC
SYNC =
Bdb::DB_TXN_SYNC
NOWAIT =
Bdb::DB_TXN_NOWAIT
WRITE_NOSYNC =
Bdb::DB_TXN_WRITE_NOSYNC
SNAPSHOT =
Bdb::DB_TXN_SNAPSHOT
READ_COMMITED =
Bdb::DB_READ_COMMITTED
READ_UNCOMMITED =
Bdb::DB_READ_UNCOMMITTED

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, flags = nil, parent = nil) ⇒ Transaction

Returns a new instance of Transaction



29
30
31
# File 'lib/sbdb/transaction.rb', line 29

def initialize env, flags = nil, parent = nil
	@txn = env.bdb_object.txn_begin parent, flags || 0
end

Class Method Details

.new(*p, &e) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sbdb/transaction.rb', line 16

def self.new *p, &e
	r = obj = super( *p)
	begin
		r = e.call obj
	rescue Object
		obj.abort
		raise $!
	ensure
		obj.commit
	end  if e
	r
end

Instance Method Details

#abortObject



37
38
39
# File 'lib/sbdb/transaction.rb', line 37

def abort
	@txn.abort
end

#bdb_objectObject



14
# File 'lib/sbdb/transaction.rb', line 14

def bdb_object()  @txn  end

#commit(flags = nil) ⇒ Object



33
34
35
# File 'lib/sbdb/transaction.rb', line 33

def commit flags = nil
	@txn.commit flags || 0
end