Class: Audrey::Engine::SQLite3::Transaction::RC

Inherits:
Audrey::Engine::SQLite3::Transaction show all
Defined in:
lib/audrey/engine/sqlite3.rb

Overview

Audrey::Engine::SQLite3::Transaction::RC An object of this class represents a transaction that can be rolled back or committed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Transaction

#exit

Constructor Details

#initialize(*opts) ⇒ RC


initialize



1237
1238
1239
1240
# File 'lib/audrey/engine/sqlite3.rb', line 1237

def initialize(*opts)
	super(*opts)
	start()
end

Instance Attribute Details

#savepointObject (readonly)

Returns the value of attribute savepoint.



1232
1233
1234
# File 'lib/audrey/engine/sqlite3.rb', line 1232

def savepoint
  @savepoint
end

Instance Method Details

#commitObject


commit



1261
1262
1263
1264
# File 'lib/audrey/engine/sqlite3.rb', line 1261

def commit
	release()
	@engine.reset_savepoints self
end

#rollbackObject


rollback



1273
1274
1275
# File 'lib/audrey/engine/sqlite3.rb', line 1273

def rollback
	@engine.dbh.execute "rollback to #{@savepoint}"
end

#startObject


start



1249
1250
1251
1252
# File 'lib/audrey/engine/sqlite3.rb', line 1249

def start
	@savepoint = Audrey::Util.randstr()
	@engine.dbh.execute "savepoint #{@savepoint}"
end

#terminateObject


terminate



1284
1285
1286
1287
# File 'lib/audrey/engine/sqlite3.rb', line 1284

def terminate
	rollback()
	release()
end