Skip to content
This repository
Browse code

Allow files in plugins to be reloaded like the rest of the applicatio…

…n. [rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit cc2d6a0b93251fce06bab15c52dbe0a5d5a8342c 1 parent a8ac530
risk danger olson technoweenie authored
15 railties/CHANGELOG
... ... @@ -1,5 +1,20 @@
1 1 *SVN*
2 2
  3 +* Allow files in plugins to be reloaded like the rest of the application. [rick]
  4 +
  5 + Enables or disables plugin reloading.
  6 +
  7 + config.reload_plugins = true
  8 +
  9 + You can get around this setting per plugin.
  10 + If #reload_plugins? == false (DEFAULT), add this to your plugin's init.rb to make it reloadable:
  11 +
  12 + Dependencies.load_once_paths.delete lib_path
  13 +
  14 + If #reload_plugins? == true, add this to your plugin's init.rb to only load it once:
  15 +
  16 + Dependencies.load_once_paths << lib_path
  17 +
3 18 * Small tweak to allow plugins to specify gem dependencies. [rick]
4 19
5 20 # OLD open_id_authentication plugin init.rb
16 railties/lib/initializer.rb
@@ -516,6 +516,22 @@ def plugins=(plugins)
516 516 # a sub class would have access to fine grained modification of the loading behavior. See
517 517 # the implementation of Rails::Plugin::Loader for more details.
518 518 attr_accessor :plugin_loader
  519 +
  520 + # Enables or disables plugin reloading. You can get around this setting per plugin.
  521 + # If #reload_plugins? == false, add this to your plugin's init.rb to make it reloadable:
  522 + #
  523 + # Dependencies.load_once_paths.delete lib_path
  524 + #
  525 + # If #reload_plugins? == true, add this to your plugin's init.rb to only load it once:
  526 + #
  527 + # Dependencies.load_once_paths << lib_path
  528 + #
  529 + attr_accessor :reload_plugins
  530 +
  531 + # Returns true if plugin reloading is enabled.
  532 + def reload_plugins?
  533 + !!@reload_plugins
  534 + end
519 535
520 536 # An array of gems that this rails application depends on. Rails will automatically load
521 537 # these gems during installation, and allow you to install any missing gems with:
4 railties/lib/rails/plugin/loader.rb
@@ -46,7 +46,9 @@ def add_plugin_load_paths
46 46 plugin.load_paths.each do |path|
47 47 $LOAD_PATH.insert(application_lib_index + 1, path)
48 48 Dependencies.load_paths << path
49   - Dependencies.load_once_paths << path
  49 + unless Rails.configuration.reload_plugins?
  50 + Dependencies.load_once_paths << path
  51 + end
50 52 end
51 53 end
52 54 $LOAD_PATH.uniq!

0 comments on commit cc2d6a0

Please sign in to comment.
Something went wrong with that request. Please try again.