Class: Neo4j::Core::CypherSession::Transactions::Driver

Inherits:
Base show all
Defined in:
lib/neo4j/core/cypher_session/transactions/driver.rb

Instance Attribute Summary collapse

Attributes inherited from Transaction::Base

#root, #session

Instance Method Summary collapse

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


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_sessionObject (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_txObject (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

#commitObject


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

#deleteObject


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_txObject


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