Class: Grumlin::TraversalStart

Inherits:
Steppable show all
Includes:
WithExtension
Defined in:
lib/grumlin/traversal_start.rb

Defined Under Namespace

Classes: AlreadyBoundToTransactionError, TraversalError

Constant Summary

Constants inherited from Steppable

Steppable::ALL_STEPS, Steppable::CONFIGURATION_STEPS, Steppable::REGULAR_STEPS, Steppable::START_STEPS

Instance Attribute Summary

Attributes inherited from Steppable

#pool, #session_id

Instance Method Summary collapse

Methods included from WithExtension

#with

Methods inherited from Steppable

#initialize, #step

Constructor Details

This class inherits a constructor from Grumlin::Steppable

Instance Method Details

#inspectObject



38
39
40
# File 'lib/grumlin/traversal_start.rb', line 38

def inspect
  self.class.inspect
end

#to_sObject



34
35
36
# File 'lib/grumlin/traversal_start.rb', line 34

def to_s(*)
  self.class.to_s
end

#txObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/grumlin/traversal_start.rb', line 9

def tx
  raise AlreadyBoundToTransactionError if @session_id

  # Pool should have size of 1 when working with session
  pool = Async::Pool::Controller.new(Grumlin::Client::PoolResource, limit: 1)

  transaction = tx_class.new(self.class, pool:, middlewares: @middlewares)
  return transaction unless block_given?

  result = nil

  begin
    result = yield transaction.begin
  rescue Grumlin::Rollback
    transaction.rollback
    result
  rescue StandardError
    transaction.rollback
    raise
  else
    transaction.commit
    result
  end
end