Skip to content

Commit

Permalink
Allow files in plugins to be reloaded like the rest of the applicatio…
Browse files Browse the repository at this point in the history
…n. [rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
technoweenie committed Mar 31, 2008
1 parent a8ac530 commit cc2d6a0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
15 changes: 15 additions & 0 deletions railties/CHANGELOG
@@ -1,5 +1,20 @@
*SVN*

* Allow files in plugins to be reloaded like the rest of the application. [rick]

Enables or disables plugin reloading.

config.reload_plugins = true

You can get around this setting per plugin.
If #reload_plugins? == false (DEFAULT), 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

* Small tweak to allow plugins to specify gem dependencies. [rick]

# OLD open_id_authentication plugin init.rb
Expand Down
16 changes: 16 additions & 0 deletions railties/lib/initializer.rb
Expand Up @@ -516,6 +516,22 @@ def plugins=(plugins)
# 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:
Expand Down
4 changes: 3 additions & 1 deletion railties/lib/rails/plugin/loader.rb
Expand Up @@ -46,7 +46,9 @@ def add_plugin_load_paths
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!
Expand Down

0 comments on commit cc2d6a0

Please sign in to comment.