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.
438 439 440 |
# File 'lib/libsql.rb', line 438 def initialize(inner) @inner = inner end |
Instance Method Details
#closed? ⇒ Boolean
471 472 473 |
# File 'lib/libsql.rb', line 471 def closed? @inner.nil? end |
#commit ⇒ Object
464 465 466 467 468 469 |
# File 'lib/libsql.rb', line 464 def commit raise ClosedException if closed? @inner.commit @inner = nil end |
#execute_batch(sql) ⇒ Object
451 452 453 454 455 |
# File 'lib/libsql.rb', line 451 def execute_batch(sql) raise ClosedException if closed? @inner.execute_batch(sql) end |
#prepare(sql) ⇒ Object
442 443 444 445 446 447 448 449 |
# File 'lib/libsql.rb', line 442 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
457 458 459 460 461 462 |
# File 'lib/libsql.rb', line 457 def rollback raise ClosedException if closed? @inner.rollback @inner = nil end |