lib/neo4j/railtie.rb in neo4j-6.0.0.alpha.5 vs lib/neo4j/railtie.rb in neo4j-6.0.0.alpha.7
- old
+ new
@@ -38,15 +38,35 @@
cfg.session_path ||= default_session_path
cfg.session_options ||= {}
cfg.sessions ||= []
end
+ def config_data
+ @config_data ||= if yaml_path
+ HashWithIndifferentAccess.new(YAML.load(yaml_path.read)[Rails.env])
+ else
+ {}
+ end
+ end
+
+ def yaml_path
+ @yaml_path ||= %w(config/neo4j.yml config/neo4j.yaml).map do |path|
+ Rails.root.join(path)
+ end.detect(&:exist?)
+ end
+
def default_session_type
- ENV['NEO4J_PATH'] ? :embedded_db : :server_db
+ if ENV['NEO4J_PATH']
+ :embedded_db
+ else
+ config_data[:type] || :server_db
+ end.to_sym
end
def default_session_path
- ENV['NEO4J_URL'] || ENV['NEO4J_PATH'] || 'http://localhost:7474'
+ ENV['NEO4J_URL'] || ENV['NEO4J_PATH'] ||
+ config_data[:url] || config_data[:path] ||
+ 'http://localhost:7474'
end
def start_embedded_session(session)
# See https://github.com/jruby/jruby/wiki/UnlimitedStrengthCrypto
security_class = java.lang.Class.for_name('javax.crypto.JceSecurity')