lib/neo4j/railtie.rb in neo4j-8.0.0.alpha.6 vs lib/neo4j/railtie.rb in neo4j-8.0.0.alpha.7

- old
+ new

@@ -34,36 +34,34 @@ rake_tasks do load 'neo4j/tasks/migration.rake' end - console do |app| + console do Neo4j::Config[:logger] = ActiveSupport::Logger.new(STDOUT) - - register_neo4j_cypher_logging(app.config.neo4j.sessions.map { |s| s[:type] }) end # Starting Neo after :load_config_initializers allows apps to # register migrations in config/initializers initializer 'neo4j.start', after: :load_config_initializers do |app| - Neo4j::ActiveBase.on_establish_session { setup! app.config.neo4j } + neo4j_config = ActiveSupport::OrderedOptions.new + app.config.neo4j.each { |k, v| neo4j_config[k] = v } if app.config.neo4j + Neo4j::Config.configuration.merge!(neo4j_config.to_h) + + Neo4j::ActiveBase.on_establish_session { setup! neo4j_config } + Neo4j::Config[:logger] ||= Rails.logger if Rails.env.development? && !Neo4j::Migrations.currently_running_migrations && Neo4j::Config.fail_on_pending_migrations Neo4j::Migrations.check_for_pending_migrations! end end - def setup!(cfg = nil) - neo4j_config ||= ActiveSupport::OrderedOptions.new - cfg.each {|k, v| neo4j_config[k] = v } if cfg - + def setup!(neo4j_config = nil) support_deprecated_session_configs!(neo4j_config) - Neo4j::Config.configuration.merge!(neo4j_config.to_h) - type, url, path, options, wait_for_connection = neo4j_config.session.values_at(:type, :path, :url, :options, :wait_for_connection) register_neo4j_cypher_logging(type || default_session_type) Neo4j::SessionManager.open_neo4j_session(type || default_session_type, url || path || default_session_path_or_url, @@ -88,17 +86,15 @@ if ENV['NEO4J_URL'] URI(ENV['NEO4J_URL']).scheme.tap do |scheme| fail "Invalid scheme for NEO4J_URL: #{scheme}" if !%w(http bolt).include?(scheme) end else - ENV['NEO4J_TYPE'] || config_data[:type] || :http + ENV['NEO4J_TYPE'] || :http end.to_sym end def default_session_path_or_url - ENV['NEO4J_URL'] || ENV['NEO4J_PATH'] || - config_data[:url] || config_data[:path] || - 'http://localhost:7474' + ENV['NEO4J_URL'] || ENV['NEO4J_PATH'] || 'http://localhost:7474' end TYPE_SUBSCRIBERS = { http: Neo4j::Core::CypherSession::Adaptors::HTTP.method(:subscribe_to_request),