Sha256: b4e7fc90a87249055fdae008ccc69f3225fb0bd9e08f48c50f8b958f793f7ea4

Contents?: true

Size: 848 Bytes

Versions: 6

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  class TraversalStart < Steppable
    include WithExtension

    class TraversalError < Grumlin::Error; end
    class AlreadyBoundToTransactionError < TraversalError; end

    def tx
      raise AlreadyBoundToTransactionError if @session_id

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

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

    def to_s(*)
      self.class.to_s
    end

    def inspect
      self.class.inspect
    end

    private

    def tx_class
      Grumlin.features.supports_transactions? ? Transaction : DummyTransaction
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
grumlin-0.22.5 lib/grumlin/traversal_start.rb
grumlin-0.22.4 lib/grumlin/traversal_start.rb
grumlin-0.22.3 lib/grumlin/traversal_start.rb
grumlin-0.22.2 lib/grumlin/traversal_start.rb
grumlin-0.22.1 lib/grumlin/traversal_start.rb
grumlin-0.22.0 lib/grumlin/traversal_start.rb