lib/motion-sqlite3/database.rb in motion-sqlite3-0.3.2 vs lib/motion-sqlite3/database.rb in motion-sqlite3-0.4.0

- old
+ new

@@ -41,9 +41,24 @@ def execute_scalar(*args) execute(*args).first.values.first end + def transaction(&block) + execute("BEGIN TRANSACTION") + + begin + result = yield + rescue + execute("ROLLBACK TRANSACTION") + raise + end + + execute("COMMIT TRANSACTION") + + result + end + private def prepare(sql, params, &block) statement = Statement.new(@handle, sql, params) result = nil