From 6f83a5036d8a9c3f8ed74755ff6d42bc3f6e9982 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 22 Jun 2010 23:17:20 +0200 Subject: renames load_(once_)paths to autoload_(once_)paths in dependencies and config --- railties/lib/rails/application.rb | 4 ++-- railties/lib/rails/application/finisher.rb | 10 +++++----- railties/lib/rails/engine.rb | 16 ++++++++-------- railties/lib/rails/engine/configuration.rb | 10 +++++----- .../generators/rails/app/templates/config/application.rb | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index eca6802297..aabe86715c 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -67,7 +67,7 @@ module Rails raise "You cannot have more than one Rails::Application" if Rails.application super Rails.application = base.instance - Rails.application.add_lib_to_load_paths! + Rails.application.add_lib_to_load_path! ActiveSupport.run_load_hooks(:before_configuration, base.instance) end @@ -97,7 +97,7 @@ module Rails # are changing config.root inside your application definition or having a custom # Rails application, you will need to add lib to $LOAD_PATH on your own in case # you need to load files in lib/ during the application configuration as well. - def add_lib_to_load_paths! #:nodoc: + def add_lib_to_load_path! #:nodoc: path = config.root.join('lib').to_s $LOAD_PATH.unshift(path) if File.exists?(path) end diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index 11a3329de6..855467227b 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -7,14 +7,14 @@ module Rails config.generators.templates.unshift(*paths.lib.templates.to_a) end - initializer :ensure_load_once_paths_as_subset do - extra = ActiveSupport::Dependencies.load_once_paths - - ActiveSupport::Dependencies.load_paths + initializer :ensure_autoload_once_paths_as_subset do + extra = ActiveSupport::Dependencies.autoload_once_paths - + ActiveSupport::Dependencies.autoload_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 * ','} + autoload_once_paths must be a subset of the autoload_paths. + Extra items in autoload_once_paths: #{extra * ','} end_error end end diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index cdb00a4eff..0a3f21fb1b 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -32,14 +32,14 @@ module Rails # == Configuration # # Besides the Railtie configuration which is shared across the application, in a - # Rails::Engine you can access load_paths, eager_load_paths and load_once_paths, + # Rails::Engine you can access autoload_paths, eager_load_paths and autoload_once_paths, # which differently from a Railtie, are scoped to the current Engine. # # Example: # # class MyEngine < Rails::Engine # # Add a load path for this specific Engine - # config.load_paths << File.expand_path("../lib/some/path", __FILE__) + # config.autoload_paths << File.expand_path("../lib/some/path", __FILE__) # # initializer "my_engine.add_middleware" do |app| # app.middleware.use MyEngine::Middleware @@ -142,7 +142,7 @@ module Rails # Add configured load paths to ruby load paths and remove duplicates. initializer :set_load_path, :before => :bootstrap_hook do - config.load_paths.reverse_each do |path| + config.autoload_paths.reverse_each do |path| $LOAD_PATH.unshift(path) if File.directory?(path) end $LOAD_PATH.uniq! @@ -154,17 +154,17 @@ module Rails # This needs to be an initializer, since it needs to run once # per engine and get the engine as a block parameter initializer :set_autoload_paths, :before => :bootstrap_hook do |app| - ActiveSupport::Dependencies.load_paths.unshift(*config.load_paths) + ActiveSupport::Dependencies.autoload_paths.unshift(*config.autoload_paths) if reloadable?(app) - ActiveSupport::Dependencies.load_once_paths.unshift(*config.load_once_paths) + ActiveSupport::Dependencies.autoload_once_paths.unshift(*config.autoload_once_paths) else - ActiveSupport::Dependencies.load_once_paths.unshift(*config.load_paths) + ActiveSupport::Dependencies.autoload_once_paths.unshift(*config.autoload_paths) end # Freeze so future modifications will fail rather than do nothing mysteriously - config.load_paths.freeze - config.load_once_paths.freeze + config.autoload_paths.freeze + config.autoload_once_paths.freeze end initializer :add_routing_paths do |app| diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index 446fe0bda9..4e27180f1e 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -4,7 +4,7 @@ module Rails class Engine class Configuration < ::Rails::Railtie::Configuration attr_reader :root - attr_writer :eager_load_paths, :load_once_paths, :load_paths + attr_writer :eager_load_paths, :autoload_once_paths, :autoload_paths def initialize(root=nil) super() @@ -41,12 +41,12 @@ module Rails @eager_load_paths ||= paths.eager_load end - def load_once_paths - @load_once_paths ||= paths.load_once + def autoload_once_paths + @autoload_once_paths ||= paths.load_once end - def load_paths - @load_paths ||= paths.load_paths + def autoload_paths + @autoload_paths ||= paths.load_paths end end end diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index 0066e2b0c2..031466cb86 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -22,7 +22,7 @@ module <%= app_const_base %> # -- all .rb files in that directory are automatically loaded. # Add additional load paths for your own custom dirs - # config.load_paths += %W( #{config.root}/extras ) + # config.autoload_paths += %W( #{config.root}/extras ) # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named -- cgit v1.2.3