Module: Pacer::ManagedTransactionsMixin

Included in:
DexGraph, Neo4jGraph, TinkerGraph
Defined in:
lib/pacer/graph/graph_transactions_mixin.rb

Overview

Methods used internally to do 'managed transactions' which I define as transactions that are started and committed automatically internally, typically on operations that potentially touch a large number of elements.

The reason for keeping track of these separately is to prevent them from being confused with manual transactions. Although when this was written, I had made manual transactions nestable. That has been since explicitly disallowed by Blueprints. I am not sure if this code is actually needed anymore (if it was refactored out).

TODO: the method names in this module need to be cleaned up. TODO: some methods may be able to be eliminated.

Instance Method Summary (collapse)

Instance Method Details

- (Object) manage_transactions=(v)



25
26
27
# File 'lib/pacer/graph/graph_transactions_mixin.rb', line 25

def manage_transactions=(v)
  @manage_transactions = v
end

- (Boolean) manage_transactions? Also known as: manage_transactions

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/pacer/graph/graph_transactions_mixin.rb', line 29

def manage_transactions?
  @manage_transactions = true if @manage_transactions.nil?
  @manage_transactions
end

- (Object) managed_checkpoint



75
76
77
# File 'lib/pacer/graph/graph_transactions_mixin.rb', line 75

def managed_checkpoint
  checkpoint if manage_transactions?
end

- (Object) managed_commit_transaction



71
72
73
# File 'lib/pacer/graph/graph_transactions_mixin.rb', line 71

def managed_commit_transaction
  commit_transaction if manage_transactions?
end

- (Object) managed_manual_transaction



51
52
53
54
55
56
57
# File 'lib/pacer/graph/graph_transactions_mixin.rb', line 51

def managed_manual_transaction
  if manage_transactions?
    manual_transaction { yield }
  else
    yield
  end
end

- (Object) managed_start_transaction



67
68
69
# File 'lib/pacer/graph/graph_transactions_mixin.rb', line 67

def managed_start_transaction
  begin_transaction if manage_transactions?
end

- (Object) managed_transaction



59
60
61
62
63
64
65
# File 'lib/pacer/graph/graph_transactions_mixin.rb', line 59

def managed_transaction
  if manage_transactions?
    transaction { yield }
  else
    yield
  end
end

- (Object) managed_transactions



43
44
45
46
47
48
49
# File 'lib/pacer/graph/graph_transactions_mixin.rb', line 43

def managed_transactions
  if manage_transactions?
    manual_transactions { yield }
  else
    yield
  end
end

- (Object) unmanaged_transactions



35
36
37
38
39
40
41
# File 'lib/pacer/graph/graph_transactions_mixin.rb', line 35

def unmanaged_transactions
  old_value = @manage_transactions
  @manage_transactions = false
  yield
ensure
  @manage_transactions = old_value
end