don't eagerload paths that have been flagged as eager_load => false #8146

Closed
wants to merge 1 commit into
from
View
2 railties/lib/rails/engine.rb
@@ -436,7 +436,7 @@ def eager_load!
config.eager_load_paths.each do |load_path|
matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/
Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
- require_dependency file.sub(matcher, '\1')
+ require_dependency file.sub(matcher, '\1') unless config.paths.skip_eager_load.any?{|path| file.match(path)}
@rafaelfranca
rafaelfranca Nov 8, 2012

If we need to exclude something we need to fix filter_by, this is not the proper place

end
end
end
View
4 railties/lib/rails/paths.rb
@@ -72,6 +72,10 @@ def autoload_once
filter_by(:autoload_once?)
end
+ def skip_eager_load
+ @skip_eager_load ||= all_paths.select{|path| !path.eager_load?}.flatten
+ end
+
def eager_load
filter_by(:eager_load?)
end