Module: Neo4j::Driver::GraphDatabase

Defined in:
lib/neo4j/driver/graph_database.rb

Overview

Main entry point for creating Neo4j drivers. Wraps the supplied AuthToken in a StaticAuthTokenManager and delegates the actual construction to Internal::DriverFactory#new_instance — same shape as Java's GraphDatabase.driver(...)DriverFactory#newInstance(...).

Class Method Summary collapse

Class Method Details

.driver(uri, auth_token = nil, auth_token_manager: nil, **config, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/neo4j/driver/graph_database.rb', line 12

def driver(uri, auth_token = nil, auth_token_manager: nil, **config, &block)
  mgr = auth_token_manager || Internal::Security::StaticAuthTokenManager.new(auth_token || AuthTokens.none)
  driver = Internal::DriverFactory.new.new_instance(uri, mgr, **config)

  if block_given?
    begin
      yield driver
    ensure
      driver.close
    end
  else
    driver
  end
end