Class: Grumlin::Transaction

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

Direct Known Subclasses

DummyTransaction

Constant Summary collapse

COMMIT =
Grumlin::Repository.new.g.step(:tx, :commit)
ROLLBACK =
Grumlin::Repository.new.g.step(:tx, :rollback)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(traversal_start_class, pool:, middlewares:) ⇒ Transaction

Returns a new instance of Transaction.



9
10
11
12
13
14
# File 'lib/grumlin/transaction.rb', line 9

def initialize(traversal_start_class, pool:, middlewares:)
  @traversal_start_class = traversal_start_class
  @pool = pool
  @session_id = SecureRandom.uuid
  @middlewares = middlewares
end

Instance Attribute Details

#poolObject (readonly)

Returns the value of attribute pool.



4
5
6
# File 'lib/grumlin/transaction.rb', line 4

def pool
  @pool
end

#session_idObject (readonly)

Returns the value of attribute session_id.



4
5
6
# File 'lib/grumlin/transaction.rb', line 4

def session_id
  @session_id
end

Instance Method Details

#beginObject



16
17
18
# File 'lib/grumlin/transaction.rb', line 16

def begin
  @traversal_start_class.new(session_id: @session_id, pool: @pool)
end

#commitObject



20
21
22
# File 'lib/grumlin/transaction.rb', line 20

def commit
  finalize(COMMIT)
end

#rollbackObject



24
25
26
# File 'lib/grumlin/transaction.rb', line 24

def rollback
  finalize(ROLLBACK)
end