aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-03-16 03:46:17 -0700
committerXavier Noria <fxn@hashref.com>2016-03-16 03:46:17 -0700
commit773d15e902846e4e66109d6cd4a63664422d9970 (patch)
treecb7a73bdec9d2085ca9093b2ebc297b632efcc93 /activesupport
parent23561ce655853b885f2bd8cc65bdefd4291595ab (diff)
parent901a4075125d8fe961b1b0a072e6e73e6c28d48e (diff)
downloadrails-773d15e902846e4e66109d6cd4a63664422d9970.tar.gz
rails-773d15e902846e4e66109d6cd4a63664422d9970.tar.bz2
rails-773d15e902846e4e66109d6cd4a63664422d9970.zip
Merge pull request #24205 from delftswa2016/improve-activesupport-dependencies
Improve ActiveSupport::Dependencies code understanding
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/dependencies.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index fc0a358645..57f6286de3 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -656,16 +656,17 @@ module ActiveSupport #:nodoc:
# and will be removed immediately.
def new_constants_in(*descs)
constant_watch_stack.watch_namespaces(descs)
- aborting = true
+ success = false
begin
yield # Now yield to the code that is to define new constants.
- aborting = false
+ success = true
ensure
new_constants = constant_watch_stack.new_constants
- return new_constants unless aborting
+ return new_constants if success
+ # Remove partially loaded constants.
new_constants.each { |c| remove_constant(c) }
end
end
@@ -734,6 +735,7 @@ module ActiveSupport #:nodoc:
begin
constantized = parent.const_get(to_remove, false)
rescue NameError
+ # The constant is no longer reachable, just skip it.
return
else
constantized.before_remove_const if constantized.respond_to?(:before_remove_const)
@@ -743,6 +745,7 @@ module ActiveSupport #:nodoc:
begin
parent.instance_eval { remove_const to_remove }
rescue NameError
+ # The constant is no longer reachable, just skip it.
end
end
end