Class: Neo4j::Core::CypherSession::Adaptors::Driver
- 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
-
#driver ⇒ Object
(also: #connected?)
readonly
Returns the value of attribute driver.
Attributes inherited from Base
Class Method Summary collapse
-
.transaction_class ⇒ Object
def transaction(_session, &block) session = driver.session(org.neo4j.driver.v1.AccessMode::WRITE) session.writeTransaction(&block) ensure session.close end.
Instance Method Summary collapse
- #close ⇒ Object
- #connect ⇒ Object
-
#initialize(url, options = {}) ⇒ Driver
constructor
A new instance of Driver.
- #query_set(transaction, queries, options = {}) ⇒ Object
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
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, = {}) self.url = url @driver = DriverRegistry.instance.driver_for(url) @options = end |
Instance Attribute Details
#driver ⇒ Object (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_class ⇒ Object
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
#close ⇒ Object
68 69 70 |
# File 'lib/neo4j/core/cypher_session/adaptors/driver.rb', line 68 def close DriverRegistry.instance.close(driver) end |
#connect ⇒ Object
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, = {}) setup_queries!(queries, transaction, skip_instrumentation: [:skip_instrumentation]) responses = queries.map do |query| transaction.root_tx.run(query.cypher, query.parameters) end wrap_level = [: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.) # , e.stack_track.to_a end |