lib/sequel_rails/railtie.rb in sequel-rails-0.9.11 vs lib/sequel_rails/railtie.rb in sequel-rails-0.9.12
- old
+ new
@@ -13,10 +13,11 @@
require 'sequel_rails/configuration'
require 'sequel_rails/migrations'
require 'sequel_rails/railties/log_subscriber'
require 'sequel_rails/railties/i18n_support'
+require 'sequel_rails/railties/spring_support'
require 'sequel_rails/railties/controller_runtime'
require 'sequel_rails/sequel/database/active_support_notification'
require 'action_dispatch/middleware/session/sequel_store'
module SequelRails
@@ -34,23 +35,29 @@
)
config.sequel = ::SequelRails::Configuration.new
rake_tasks do |app|
- load 'sequel_rails/railties/database.rake' if app.config.sequel.load_database_tasks
+ load_tasks_config = app.config.sequel.load_database_tasks
+ SequelRails::TASK_NAMESPACE =
+ case load_tasks_config
+ when Symbol, String then load_tasks_config.to_sym
+ else :db
+ end
+ load 'sequel_rails/railties/database.rake' if load_tasks_config
end
- initializer 'sequel.load_hooks' do |app|
+ initializer 'sequel.load_hooks' do
::ActiveSupport.run_load_hooks(:sequel, ::Sequel::Model)
end
initializer 'sequel.configuration' do |app|
configure_sequel app
end
initializer 'sequel.logger' do |app|
- setup_logger app, ::Rails.logger
+ app.config.sequel.logger ||= ::Rails.logger
end
initializer 'sequel.i18n_support' do |_app|
setup_i18n_support
end
@@ -59,12 +66,19 @@
initializer 'sequel.log_runtime' do |_app|
setup_controller_runtime
end
initializer 'sequel.connect' do |app|
- unless app.config.sequel[:skip_connect]
- ::SequelRails.setup ::Rails.env
+ ::SequelRails.setup ::Rails.env unless app.config.sequel[:skip_connect]
+ end
+
+ initializer 'sequel.spring' do |app|
+ if defined?(::Spring::Application)
+ class ::Spring::Application
+ include ::SequelRails::SpringSupport
+ alias_method_chain :disconnect_database, :sequel
+ end
end
end
# Support overwriting crucial steps in subclasses
def configure_sequel(app)
@@ -87,12 +101,8 @@
end
def setup_controller_runtime
require 'sequel_rails/railties/controller_runtime'
ActionController::Base.send :include, SequelRails::Railties::ControllerRuntime
- end
-
- def setup_logger(app, logger)
- app.config.sequel.logger = logger
end
end
end