lib/grumlin/traversal_start.rb in grumlin-0.23.0 vs lib/grumlin/traversal_start.rb in grumlin-1.0.0.rc1
- old
+ new
@@ -1,42 +1,40 @@
# frozen_string_literal: true
-module Grumlin
- class TraversalStart < Steppable
- include WithExtension
+class Grumlin::TraversalStart < Grumlin::Steppable
+ include Grumlin::WithExtension
- class TraversalError < Grumlin::Error; end
- class AlreadyBoundToTransactionError < TraversalError; end
+ class TraversalError < Grumlin::Error; end
+ class AlreadyBoundToTransactionError < TraversalError; end
- def tx
- raise AlreadyBoundToTransactionError if @session_id
+ def tx
+ raise AlreadyBoundToTransactionError if @session_id
- transaction = tx_class.new(self.class, pool: @pool, middlewares: @middlewares)
- return transaction unless block_given?
+ transaction = tx_class.new(self.class, pool: @pool, middlewares: @middlewares)
+ return transaction unless block_given?
- begin
- yield transaction.begin
- rescue Grumlin::Rollback
- transaction.rollback
- rescue StandardError
- transaction.rollback
- raise
- else
- transaction.commit
- end
+ 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 to_s(*)
+ self.class.to_s
+ end
- def inspect
- self.class.inspect
- end
+ def inspect
+ self.class.inspect
+ end
- private
+ private
- def tx_class
- Grumlin.features.supports_transactions? ? Transaction : DummyTransaction
- end
+ def tx_class
+ Grumlin.features.supports_transactions? ? Grumlin::Transaction : Grumlin::DummyTransaction
end
end