diff options
author | Jan Habermann <jan@habermann.io> | 2018-10-18 19:05:20 +0200 |
---|---|---|
committer | Jan Habermann <jan@habermann.io> | 2018-10-28 16:34:50 +0100 |
commit | e302725751fc4bdb26aa3d28ca5d934ec21319f9 (patch) | |
tree | deebadcfbf219a1c38419a464cb636555773d7bf /activesupport/lib | |
parent | 3295e23755744b7f9426d752481bb928fb02a89e (diff) | |
download | rails-e302725751fc4bdb26aa3d28ca5d934ec21319f9.tar.gz rails-e302725751fc4bdb26aa3d28ca5d934ec21319f9.tar.bz2 rails-e302725751fc4bdb26aa3d28ca5d934ec21319f9.zip |
Improve the logic that detects non-autoloaded constants
If you require `nokogiri` from `app/models/user.rb`, dependencies.rb
does not mark `Nokogiri` as an autoloaded constant, as expected.
But the logic to detect these non-autoloaded constants is incomplete.
See the tests defined in the patch for some cases incorrectly handled.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 66e0bea00e..d5d00b5e6e 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -103,6 +103,8 @@ module ActiveSupport #:nodoc: # parent.rb then requires namespace/child.rb, the stack will look like # [[Object], [Namespace]]. + attr_reader :watching + def initialize @watching = [] @stack = Hash.new { |h, k| h[k] = [] } @@ -254,7 +256,9 @@ module ActiveSupport #:nodoc: def load_dependency(file) if Dependencies.load? && Dependencies.constant_watch_stack.watching? - Dependencies.new_constants_in(Object) { yield } + descs = Dependencies.constant_watch_stack.watching.flatten.uniq + + Dependencies.new_constants_in(*descs) { yield } else yield end |