Class: Libsql::Transaction
- Inherits:
-
Object
- Object
- Libsql::Transaction
- Includes:
- Prepareable
- Defined in:
- lib/libsql.rb
Instance Method Summary collapse
- #closed? ⇒ Boolean
- #commit ⇒ Object
- #execute_batch(sql) ⇒ Object
-
#initialize(inner) ⇒ Transaction
constructor
A new instance of Transaction.
- #prepare(sql) ⇒ Object
- #rollback ⇒ Object
Methods included from Prepareable
Constructor Details
#initialize(inner) ⇒ Transaction
Returns a new instance of Transaction.
436 437 438 |
# File 'lib/libsql.rb', line 436 def initialize(inner) @inner = inner end |
Instance Method Details
#closed? ⇒ Boolean
469 470 471 |
# File 'lib/libsql.rb', line 469 def closed? @inner.nil? end |
#commit ⇒ Object
462 463 464 465 466 467 |
# File 'lib/libsql.rb', line 462 def commit raise ClosedException if closed? @inner.commit @inner = nil end |
#execute_batch(sql) ⇒ Object
449 450 451 452 453 |
# File 'lib/libsql.rb', line 449 def execute_batch(sql) raise ClosedException if closed? @inner.execute_batch(sql) end |
#prepare(sql) ⇒ Object
440 441 442 443 444 445 446 447 |
# File 'lib/libsql.rb', line 440 def prepare(sql) raise ClosedException if closed? stmt = Statement.new @inner.prepare sql return stmt unless block_given? begin yield stmt ensure stmt.close end end |
#rollback ⇒ Object
455 456 457 458 459 460 |
# File 'lib/libsql.rb', line 455 def rollback raise ClosedException if closed? @inner.rollback @inner = nil end |