Plugin loading internals have changed, for the better!

Until now, the task of locating and loading plugins into your app was handled by a handful of private methods on the
Rails::Initializer. These methods were fairly large, coarse grained, and as a result hard to hook into without resorting
to fragile cut and paste if you wanted to customize how your plugins are loaded.

New in Edge Rails, changeset 6277 replaces this smattering of methods with two new internal classes, Rails::Plugin::Locater and Rails::Plugin::Loader. If you need to hook into how plugins are loaded, you can define a subclass of Rails::Plugin::Loader, then register your custom class to be the class that handles plugin loading using the new plugin_loader configuration option in your config/environement.rb:


  Rails::Initializer.run do |config|
    # Config settings...
    config.plugin_loader = PluginLoaderWithDependencies
  end

This should make extensions on top of the plugin system, such as the Plugems approach developed by the team over at Revolution Health, far easier to implement and maintain.

To those monkey patching the plugin loading subsystem in Rails, this introduces substantial changes to the way that plugins are located and loaded. In the short term this might mean that your customizations to the internals will very likely break, but the good news is that in the long term the new implementation will be far easier to customize.

For those adventurous early adopters living on the Rails Edge, please give your apps a test run to ensure these changes
don’t break anything for you. As always, bug reports and patches are welcome: http://dev.rubyonrails.org/.

blog comments powered by Disqus