From 924fa084e81b8b2f5ae9eab93d6b711c2b6b89d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 23 Jan 2010 17:13:25 +0100 Subject: First steps into making Plugin < Engine. --- railties/lib/rails/engine.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'railties/lib/rails/engine.rb') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index cf6ca7c3f5..b11c1ac73e 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -42,6 +42,10 @@ module Rails delegate :middleware, :paths, :root, :config, :to => :'self.class' + def reloadable?(app) + app.config.reload_plugins + end + # Add configured load paths to ruby load paths and remove duplicates. initializer :set_load_path do config.load_paths.reverse_each do |path| @@ -52,21 +56,17 @@ module Rails # Set the paths from which Rails will automatically load source files, # and the load_once paths. - initializer :set_autoload_paths do + initializer :set_autoload_paths do |app| ActiveSupport::Dependencies.load_paths.concat(config.load_paths) - ActiveSupport::Dependencies.load_once_paths.concat(config.load_once_paths) - - extra = ActiveSupport::Dependencies.load_once_paths - - ActiveSupport::Dependencies.load_paths - unless extra.empty? - abort <<-end_error - load_once_paths must be a subset of the load_paths. - Extra items in load_once_paths: #{extra * ','} - end_error + if reloadable?(app) + ActiveSupport::Dependencies.load_once_paths.concat(config.load_once_paths) + else + ActiveSupport::Dependencies.load_once_paths.concat(config.load_paths) end # Freeze so future modifications will fail rather than do nothing mysteriously + config.load_paths.freeze config.load_once_paths.freeze end -- cgit v1.2.3