aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2008-03-31 06:53:44 +0000
committerRick Olson <technoweenie@gmail.com>2008-03-31 06:53:44 +0000
commitcc2d6a0b93251fce06bab15c52dbe0a5d5a8342c (patch)
treeb3bb8eb90221ae4c83fea9a78238abb9c39e8641 /railties/lib
parenta8ac5300e657f523fd27c54283b3fd27fb1afdd8 (diff)
downloadrails-cc2d6a0b93251fce06bab15c52dbe0a5d5a8342c.tar.gz
rails-cc2d6a0b93251fce06bab15c52dbe0a5d5a8342c.tar.bz2
rails-cc2d6a0b93251fce06bab15c52dbe0a5d5a8342c.zip
Allow files in plugins to be reloaded like the rest of the application. [rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/initializer.rb16
-rw-r--r--railties/lib/rails/plugin/loader.rb4
2 files changed, 19 insertions, 1 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 20e1f01926..40c2ad90cb 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -516,6 +516,22 @@ module Rails
# a sub class would have access to fine grained modification of the loading behavior. See
# the implementation of Rails::Plugin::Loader for more details.
attr_accessor :plugin_loader
+
+ # Enables or disables plugin reloading. You can get around this setting per plugin.
+ # If #reload_plugins? == false, add this to your plugin's init.rb to make it reloadable:
+ #
+ # Dependencies.load_once_paths.delete lib_path
+ #
+ # If #reload_plugins? == true, add this to your plugin's init.rb to only load it once:
+ #
+ # Dependencies.load_once_paths << lib_path
+ #
+ attr_accessor :reload_plugins
+
+ # Returns true if plugin reloading is enabled.
+ def reload_plugins?
+ !!@reload_plugins
+ end
# An array of gems that this rails application depends on. Rails will automatically load
# these gems during installation, and allow you to install any missing gems with:
diff --git a/railties/lib/rails/plugin/loader.rb b/railties/lib/rails/plugin/loader.rb
index 438afa4d32..1e542dd038 100644
--- a/railties/lib/rails/plugin/loader.rb
+++ b/railties/lib/rails/plugin/loader.rb
@@ -46,7 +46,9 @@ module Rails
plugin.load_paths.each do |path|
$LOAD_PATH.insert(application_lib_index + 1, path)
Dependencies.load_paths << path
- Dependencies.load_once_paths << path
+ unless Rails.configuration.reload_plugins?
+ Dependencies.load_once_paths << path
+ end
end
end
$LOAD_PATH.uniq!