-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfiguration.rb
41 lines (37 loc) · 1.33 KB
/
configuration.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true
module Neo4j
module Http
class Configuration
attr_accessor :database_name
attr_accessor :password
attr_accessor :request_timeout_in_seconds
attr_accessor :uri
attr_accessor :user
attr_accessor :user_agent
attr_accessor :access_mode
def initialize(options = ENV)
@uri = options.fetch("NEO4J_URL", "http://localhost:7474")
@user = options.fetch("NEO4J_USER", "")
@password = options.fetch("NEO4J_PASSWORD", "")
@database_name = options.fetch("NEO4J_DATABASE", nil)
@user_agent = options.fetch("NEO4J_HTTP_USER_AGENT", "Ruby Neo4j Http Client")
@request_timeout_in_seconds = options.fetch("NEO4J_REQUEST_TIMEOUT_IN_SECONDS", nil)
@access_mode = options.fetch("NEO4J_ACCESS_MODE", "WRITE")
end
# https://neo4j.com/developer/manage-multiple-databases/
# https://neo4j.com/docs/upgrade-migration-guide/current/migration/surface-changes/http-api/
def transaction_path
# v3.5 - /db/data/transaction/commit
# v4.x - /db/#{database_name}/tx/commit
if database_name
"/db/#{database_name}/tx/commit"
else
"/db/data/transaction/commit"
end
end
def auth_token
Neo4j::Http::AuthToken.token(user, password)
end
end
end
end