aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/plugin.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-03-23 23:50:24 +0100
committerJosé Valim <jose.valim@gmail.com>2010-03-23 23:50:53 +0100
commit5c41cb77d9af28fe6495d5c4047483ce3ceadfe6 (patch)
treecc9ab8088b2d3b05d372db80bb77d79c8f52b32e /railties/lib/rails/plugin.rb
parentcc0e402aa870fa710d6b6189dc090244b4462308 (diff)
downloadrails-5c41cb77d9af28fe6495d5c4047483ce3ceadfe6.tar.gz
rails-5c41cb77d9af28fe6495d5c4047483ce3ceadfe6.tar.bz2
rails-5c41cb77d9af28fe6495d5c4047483ce3ceadfe6.zip
Ensure lib/rails/initializers/*.rb also works for gems.
Diffstat (limited to 'railties/lib/rails/plugin.rb')
-rw-r--r--railties/lib/rails/plugin.rb19
1 files changed, 6 insertions, 13 deletions
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb
index 5d6144959d..a08c5b9143 100644
--- a/railties/lib/rails/plugin.rb
+++ b/railties/lib/rails/plugin.rb
@@ -47,20 +47,13 @@ module Rails
end
initializer :load_init_rb, :before => :load_application_initializers do |app|
- initializers = Dir["#{root}/lib/rails/initializers/*.rb"]
+ lib_initializers = paths.lib.rails.initializers.to_a
+ files = %w(rails/init.rb init.rb).map { |path| File.expand_path(path, root) }
- if initializers.any?
- initializers.each do |initializer|
- config = app.config
- eval(File.read(initializer), binding, initializer)
- end
- else
- files = %w(rails/init.rb init.rb).map { |path| File.expand_path path, root }
- if initrb = files.find { |path| File.file? path }
- ActiveSupport::Deprecation.warn "init.rb is deprecated: #{initrb}. Use lib/rails/initializers/#{name}.rb"
- config = app.config
- eval(File.read(initrb), binding, initrb)
- end
+ if lib_initializers.empty? && initrb = files.find { |path| File.file?(path) }
+ ActiveSupport::Deprecation.warn "init.rb is deprecated: #{initrb}. Use lib/rails/initializers/#{name}.rb"
+ config = app.config
+ eval(File.read(initrb), binding, initrb)
end
end