Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 4 additions and 9 deletions.
  1. +4 −9 lib/pacer/graph/graph_transactions_mixin.rb
View
13 lib/pacer/graph/graph_transactions_mixin.rb
@@ -1,14 +1,9 @@
module Pacer
import com.tinkerpop.blueprints.TransactionalGraph
- # Add features to transactions to allow them to be more rubyish and
- # more convenient to use.
- #
- # TODO: the method names in this module need to be cleaned up.
- # TODO: some methods may be able to be eliminated.
module GraphTransactionsMixin
def in_transaction?
- threadlocal_graph_info[:tx_depth] > 0
+ threadlocal_graph_info.fetch(:tx_depth, 0) > 0
end
# Basic usage:
@@ -69,7 +64,7 @@ def start_transaction!(opts)
elsif opts[:nesting] == true
nested_tx_finalizers
else
- fail NestedTransactionError
+ fail NestedTransactionError, "To use nested transactions, use nesting: true"
end
else
if tx_depth == 0
@@ -81,14 +76,14 @@ def start_transaction!(opts)
end
def finish_transaction!
- threadlocal_graph_info[:tx_depth] -= 1
+ threadlocal_graph_info[:tx_depth] -= 1 rescue nil
end
def base_tx_finalizers
tx_id = threadlocal_graph_info[:tx_id] = rand
commit = -> do
if tx_id != threadlocal_graph_info[:tx_id]
- fail InternalError
+ fail InternalError, 'Can not commit transaction outside its original block'
end
puts "transaction committed" if Pacer.verbose == :very
blueprints_graph.stopTransaction TransactionalGraph::Conclusion::SUCCESS

No commit comments for this range

Something went wrong with that request. Please try again.