Class: Libsql::Connection
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #execute_batch(sql) ⇒ Object
-
#initialize(inner) ⇒ Connection
constructor
A new instance of Connection.
- #prepare(sql) ⇒ Object
- #transaction ⇒ Object
Methods included from Prepareable
Constructor Details
#initialize(inner) ⇒ Connection
Returns a new instance of Connection.
479 480 481 |
# File 'lib/libsql.rb', line 479 def initialize(inner) @inner = inner end |
Instance Method Details
#close ⇒ Object
512 513 514 515 516 517 |
# File 'lib/libsql.rb', line 512 def close raise ClosedException if closed? @inner.deinit @inner = nil end |
#closed? ⇒ Boolean
519 520 521 |
# File 'lib/libsql.rb', line 519 def closed? @inner.nil? end |
#execute_batch(sql) ⇒ Object
510 |
# File 'lib/libsql.rb', line 510 def execute_batch(sql) = @inner.execute_batch(sql) |
#prepare(sql) ⇒ Object
500 501 502 503 504 505 506 507 508 |
# File 'lib/libsql.rb', line 500 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 |
#transaction ⇒ Object
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
# File 'lib/libsql.rb', line 483 def transaction raise ClosedException if closed? tx = Transaction.new @inner.transaction return tx unless block_given? abort = false begin yield self rescue StandardError abort = true raise ensure abort and tx.rollback or tx.commit end end |