Class: Libsql::Transaction

Inherits:
Object
  • Object
show all
Includes:
Prepareable
Defined in:
lib/libsql.rb

Instance Method Summary collapse

Methods included from Prepareable

#execute, #query

Constructor Details

#initialize(inner) ⇒ Transaction



446
447
448
# File 'lib/libsql.rb', line 446

def initialize(inner)
  @inner = inner
end

Instance Method Details

#closed?Boolean



479
480
481
# File 'lib/libsql.rb', line 479

def closed?
  @inner.nil?
end

#commitObject

Raises:



472
473
474
475
476
477
# File 'lib/libsql.rb', line 472

def commit
  raise ClosedException if closed?

  @inner.commit
  @inner = nil
end

#execute_batch(sql) ⇒ Object

Raises:



459
460
461
462
463
# File 'lib/libsql.rb', line 459

def execute_batch(sql)
  raise ClosedException if closed?

  @inner.execute_batch(sql)
end

#prepare(sql) ⇒ Object

Raises:



450
451
452
453
454
455
456
457
# File 'lib/libsql.rb', line 450

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

#rollbackObject

Raises:



465
466
467
468
469
470
# File 'lib/libsql.rb', line 465

def rollback
  raise ClosedException if closed?

  @inner.rollback
  @inner = nil
end