Class: Hyperion::Sql::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperion/sql/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Transaction

Returns a new instance of Transaction.



9
10
11
# File 'lib/hyperion/sql/transaction.rb', line 9

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



7
8
9
# File 'lib/hyperion/sql/transaction.rb', line 7

def connection
  @connection
end

Instance Method Details

#beginObject



13
14
15
# File 'lib/hyperion/sql/transaction.rb', line 13

def begin
  run "BEGIN"
end

#begin_savepointObject



25
26
27
28
29
# File 'lib/hyperion/sql/transaction.rb', line 25

def begin_savepoint
  id = new_savepoint_id
  run %{SAVEPOINT "#{id}"}
  id
end

#commitObject



17
18
19
# File 'lib/hyperion/sql/transaction.rb', line 17

def commit
  run "COMMIT"
end

#release_savepoint(id) ⇒ Object



31
32
33
# File 'lib/hyperion/sql/transaction.rb', line 31

def release_savepoint(id)
  run %{RELEASE SAVEPOINT "#{id}"}
end

#rollbackObject



21
22
23
# File 'lib/hyperion/sql/transaction.rb', line 21

def rollback
  run "ROLLBACK"
end

#rollback_to_savepoint(id) ⇒ Object



35
36
37
# File 'lib/hyperion/sql/transaction.rb', line 35

def rollback_to_savepoint(id)
  run %{ROLLBACK TO SAVEPOINT "#{id}"}
end