lib/grumlin/transaction.rb in grumlin-0.23.0 vs lib/grumlin/transaction.rb in grumlin-1.0.0.rc1
- old
+ new
@@ -1,40 +1,38 @@
# frozen_string_literal: true
-module Grumlin
- class Transaction
- attr_reader :session_id
+class Grumlin::Transaction
+ attr_reader :session_id
- include Console
+ include Console
- COMMIT = Grumlin::Repository.new.g.step(:tx, :commit)
- ROLLBACK = Grumlin::Repository.new.g.step(:tx, :rollback)
+ COMMIT = Grumlin::Repository.new.g.step(:tx, :commit)
+ ROLLBACK = Grumlin::Repository.new.g.step(:tx, :rollback)
- def initialize(traversal_start_class, pool:, middlewares:)
- @traversal_start_class = traversal_start_class
- @pool = pool
- @session_id = SecureRandom.uuid
- @middlewares = middlewares
- end
+ def initialize(traversal_start_class, pool:, middlewares:)
+ @traversal_start_class = traversal_start_class
+ @pool = pool
+ @session_id = SecureRandom.uuid
+ @middlewares = middlewares
+ end
- def begin
- @traversal_start_class.new(session_id: @session_id)
- end
+ def begin
+ @traversal_start_class.new(session_id: @session_id)
+ end
- def commit
- finalize(COMMIT)
- end
+ def commit
+ finalize(COMMIT)
+ end
- def rollback
- finalize(ROLLBACK)
- end
+ def rollback
+ finalize(ROLLBACK)
+ end
- private
+ private
- def finalize(step)
- @middlewares.call(traversal: step,
- need_results: false,
- session_id: @session_id,
- pool: @pool)
- end
+ def finalize(step)
+ @middlewares.call(traversal: step,
+ need_results: false,
+ session_id: @session_id,
+ pool: @pool)
end
end