diff options
author | José Valim <jose.valim@gmail.com> | 2009-12-27 13:31:36 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-12-27 13:31:36 +0100 |
commit | 7e8b7f46bfc086a36db996420fbee93348c5268e (patch) | |
tree | 7c4e309b378ce6a3d39c60785efc603619e25ac8 /railties/lib/rails/plugin.rb | |
parent | 75ba102a80965b2612df0253d1278581a88b8d66 (diff) | |
download | rails-7e8b7f46bfc086a36db996420fbee93348c5268e.tar.gz rails-7e8b7f46bfc086a36db996420fbee93348c5268e.tar.bz2 rails-7e8b7f46bfc086a36db996420fbee93348c5268e.zip |
Add config.action_controller.include behavior to plugins.
Diffstat (limited to 'railties/lib/rails/plugin.rb')
-rw-r--r-- | railties/lib/rails/plugin.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index 0699affea7..aa325c6f76 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -25,6 +25,24 @@ module Rails Configuration.default end + # Creates an initializer which includes all given modules to the given class. + # + # module Rails + # class ActionController < Rails::Plugin + # plugin_name :action_controller + # include_modules_in "ActionController::Base" + # end + # end + # + def self.include_modules_in(klass, from=plugin_name) + self.initializer :"#{from}.include_modules" do |app| + klass = klass.constantize if klass.is_a?(String) + app.config.send(from).includes.each do |mod| + klass.send(:include, mod.is_a?(String) ? mod.constantize : mod) + end + end + end + class Vendored < Plugin def self.all(list, paths) plugins = [] |