Class: Neo4j::Transaction::Base
- Inherits:
-
Object
- Object
- Neo4j::Transaction::Base
show all
- Defined in:
- lib/neo4j/transaction.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(session, _options = {}) ⇒ Base
Returns a new instance of Base.
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/neo4j/transaction.rb', line 18
def initialize(session, _options = {})
@session = session
Transaction.stack_for(session) << self
@root = Transaction.stack_for(session).first
end
|
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
16
17
18
|
# File 'lib/neo4j/transaction.rb', line 16
def root
@root
end
|
#session ⇒ Object
Returns the value of attribute session.
16
17
18
|
# File 'lib/neo4j/transaction.rb', line 16
def session
@session
end
|
Instance Method Details
#autoclosed! ⇒ Object
57
58
59
|
# File 'lib/neo4j/transaction.rb', line 57
def autoclosed!
@autoclosed = true if transient_failures_autoclose?
end
|
#close ⇒ Object
Commits or marks this transaction for rollback, depending on whether #mark_failed has been previously invoked.
39
40
41
42
43
44
45
46
47
|
# File 'lib/neo4j/transaction.rb', line 39
def close
tx_stack = Transaction.stack_for(@session)
fail 'Tried closing when transaction stack is empty (maybe you closed too many?)' if tx_stack.empty?
fail "Closed transaction which wasn't the most recent on the stack (maybe you forgot to close one?)" if tx_stack.pop != self
@closed = true
post_close! if tx_stack.empty?
end
|
#closed? ⇒ Boolean
61
62
63
|
# File 'lib/neo4j/transaction.rb', line 61
def closed?
!!@closed
end
|
#commit ⇒ Object
53
54
55
|
# File 'lib/neo4j/transaction.rb', line 53
def commit
fail 'not implemented'
end
|
#delete ⇒ Object
49
50
51
|
# File 'lib/neo4j/transaction.rb', line 49
def delete
fail 'not implemented'
end
|
#expired? ⇒ Boolean
87
88
89
|
# File 'lib/neo4j/transaction.rb', line 87
def expired?
!!@expired
end
|
#failed? ⇒ Boolean
Also known as:
failure?
If it has been marked as failed. Aliased for legacy purposes.
77
78
79
|
# File 'lib/neo4j/transaction.rb', line 77
def failed?
!!@failure
end
|
#inspect ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/neo4j/transaction.rb', line 30
def inspect
status_string = [:id, :failed?, :active?, :commit_url].map do |method|
"#{method}: #{send(method)}" if respond_to?(method)
end.compact.join(', ')
"<#{self.class} [#{status_string}]"
end
|
#mark_expired ⇒ Object
82
83
84
85
|
# File 'lib/neo4j/transaction.rb', line 82
def mark_expired
@parent.mark_expired if @parent
@expired = true
end
|
#mark_failed ⇒ Object
Also known as:
failure
Marks this transaction as failed, which means that it will unconditionally be rolled back when #close is called. Aliased for legacy purposes.
69
70
71
72
|
# File 'lib/neo4j/transaction.rb', line 69
def mark_failed
root.mark_failed if root && root != self
@failure = true
end
|
#root? ⇒ Boolean
91
92
93
|
# File 'lib/neo4j/transaction.rb', line 91
def root?
@root == self
end
|