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.
449 450 451 |
# File 'lib/libsql.rb', line 449 def initialize(inner) @inner = inner end |
Instance Method Details
#closed? ⇒ Boolean
482 483 484 |
# File 'lib/libsql.rb', line 482 def closed? @inner.nil? end |
#commit ⇒ Object
475 476 477 478 479 480 |
# File 'lib/libsql.rb', line 475 def commit raise ClosedException if closed? @inner.commit @inner = nil end |
#execute_batch(sql) ⇒ Object
462 463 464 465 466 |
# File 'lib/libsql.rb', line 462 def execute_batch(sql) raise ClosedException if closed? @inner.execute_batch(sql) end |
#prepare(sql) ⇒ Object
453 454 455 456 457 458 459 460 |
# File 'lib/libsql.rb', line 453 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
468 469 470 471 472 473 |
# File 'lib/libsql.rb', line 468 def rollback raise ClosedException if closed? @inner.rollback @inner = nil end |