Class: Neo4j::Core::CypherSession::Adaptors::Driver

Inherits:
Base
  • Object
show all
Includes:
HasUri, Schema
Defined in:
lib/neo4j/core/cypher_session/adaptors/driver.rb

Constant Summary

Constants inherited from Base

Base::EMPTY, Base::NEWLINE_W_SPACES, Base::USER_AGENT_STRING

Instance Attribute Summary collapse

Attributes inherited from Base

#options, #wrap_level

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Schema

#constraints, #indexes, #version

Methods included from HasUri

#url, #url=, #url_without_password

Methods inherited from Base

#default_subscribe, #logger, #queries, #query, #setup_queries!, #supports_metadata?, #transaction

Methods included from Instrumentable

included

Constructor Details

#initialize(url, options = {}) ⇒ Driver

Returns a new instance of Driver.



60
61
62
63
64
# File 'lib/neo4j/core/cypher_session/adaptors/driver.rb', line 60

def initialize(url, options = {})
  self.url = url
  @driver = DriverRegistry.instance.driver_for(url)
  @options = options
end

Instance Attribute Details

#driverObject (readonly) Also known as: connected?

Returns the value of attribute driver.



57
58
59
# File 'lib/neo4j/core/cypher_session/adaptors/driver.rb', line 57

def driver
  @driver
end

Class Method Details

.transaction_classObject

def transaction(_session, &block)

session = driver.session(org.neo4j.driver.v1.AccessMode::WRITE)
session.writeTransaction(&block)

ensure

session.close

end



91
92
93
94
# File 'lib/neo4j/core/cypher_session/adaptors/driver.rb', line 91

def self.transaction_class
  require 'neo4j/core/cypher_session/transactions/driver'
  Neo4j::Core::CypherSession::Transactions::Driver
end

Instance Method Details

#closeObject



68
69
70
# File 'lib/neo4j/core/cypher_session/adaptors/driver.rb', line 68

def close
  DriverRegistry.instance.close(driver)
end

#connectObject



66
# File 'lib/neo4j/core/cypher_session/adaptors/driver.rb', line 66

def connect; end

#query_set(transaction, queries, options = {}) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/neo4j/core/cypher_session/adaptors/driver.rb', line 72

def query_set(transaction, queries, options = {})
  setup_queries!(queries, transaction, skip_instrumentation: options[:skip_instrumentation])

  responses = queries.map do |query|
    transaction.root_tx.run(query.cypher, query.parameters)
  end
  wrap_level = options[:wrap_level] || @options[:wrap_level]
  Responses::Driver.new(responses, wrap_level: wrap_level).results
rescue Neo4j::Driver::Exceptions::Neo4jException => e
  raise Neo4j::Core::CypherSession::CypherError.new_from(e.code, e.message) # , e.stack_track.to_a
end