Class: Neo4j::Core::CypherSession::Transactions::Driver
- Inherits:
-
Base
- Object
- Transaction::Base
- Base
- Neo4j::Core::CypherSession::Transactions::Driver
- Defined in:
- lib/neo4j/core/cypher_session/transactions/driver.rb
Instance Attribute Summary collapse
-
#driver_session ⇒ Object
readonly
Returns the value of attribute driver_session.
-
#driver_tx ⇒ Object
readonly
Returns the value of attribute driver_tx.
Attributes inherited from Transaction::Base
Instance Method Summary collapse
- #commit ⇒ Object
- #delete ⇒ Object
-
#initialize(*args) ⇒ Driver
constructor
A new instance of Driver.
- #root_tx ⇒ Object
- #started? ⇒ Boolean
Methods inherited from Base
#after_commit, #after_commit_registry, #post_close!, #queries, #query
Methods inherited from Transaction::Base
#autoclosed!, #close, #closed?, #expired?, #failed?, #inspect, #mark_expired, #mark_failed, #root?
Constructor Details
#initialize(*args) ⇒ Driver
Returns a new instance of Driver.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/neo4j/core/cypher_session/transactions/driver.rb', line 10 def initialize(*args) super return unless root? @driver_session = session.adaptor.driver.session(Neo4j::Driver::AccessMode::WRITE) @driver_tx = @driver_session.begin_transaction rescue StandardError => e clean_transaction_registry @driver_tx.close if @driver_tx @driver_session.close if @driver_session raise e end |
Instance Attribute Details
#driver_session ⇒ Object (readonly)
Returns the value of attribute driver_session.
8 9 10 |
# File 'lib/neo4j/core/cypher_session/transactions/driver.rb', line 8 def driver_session @driver_session end |
#driver_tx ⇒ Object (readonly)
Returns the value of attribute driver_tx.
8 9 10 |
# File 'lib/neo4j/core/cypher_session/transactions/driver.rb', line 8 def driver_tx @driver_tx end |
Instance Method Details
#commit ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/neo4j/core/cypher_session/transactions/driver.rb', line 22 def commit return unless root? begin @driver_tx.success @driver_tx.close ensure @driver_session.close end end |
#delete ⇒ Object
32 33 34 35 36 |
# File 'lib/neo4j/core/cypher_session/transactions/driver.rb', line 32 def delete root.driver_tx.failure root.driver_tx.close root.driver_session.close end |
#root_tx ⇒ Object
42 43 44 |
# File 'lib/neo4j/core/cypher_session/transactions/driver.rb', line 42 def root_tx root.driver_tx end |
#started? ⇒ Boolean
38 39 40 |
# File 'lib/neo4j/core/cypher_session/transactions/driver.rb', line 38 def started? true end |