mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix Reloadable to handle the case where a class that has been 'removed' has not yet been garbage collected.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3528 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
62aa0603b7
commit
1aaeb2113b
3 changed files with 9 additions and 7 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Fix Reloadable to handle the case where a class that has been 'removed' has not yet been garbage collected. [Nicholas Seckar]
|
||||
|
||||
* Don't allow Reloadable to be included into Modules.
|
||||
|
||||
* Remove LoadingModule. [Nicholas Seckar]
|
||||
|
|
|
@ -9,8 +9,15 @@ class Class #:nodoc:
|
|||
|
||||
def remove_class(*klasses)
|
||||
klasses.each do |klass|
|
||||
# Skip this class if there is nothing bound to this name
|
||||
next unless defined?(klass.name)
|
||||
|
||||
basename = klass.to_s.split("::").last
|
||||
parent = klass.parent
|
||||
|
||||
# Skip this class if it does not match the current one bound to this name
|
||||
next unless klass = parent.const_get(basename)
|
||||
|
||||
parent.send :remove_const, basename unless parent == klass
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,9 +5,6 @@ require File.dirname(__FILE__) + '/../lib/active_support/reloadable'
|
|||
|
||||
module ReloadableTestSandbox
|
||||
|
||||
module AModuleIncludingReloadable
|
||||
include Reloadable
|
||||
end
|
||||
class AReloadableClass
|
||||
include Reloadable
|
||||
end
|
||||
|
@ -43,9 +40,6 @@ module ReloadableTestSandbox
|
|||
end
|
||||
|
||||
class ReloadableTest < Test::Unit::TestCase
|
||||
def test_modules_do_not_receive_reloadable_method
|
||||
assert ! ReloadableTestSandbox::AModuleIncludingReloadable.respond_to?(:reloadable?)
|
||||
end
|
||||
def test_classes_receive_reloadable
|
||||
assert ReloadableTestSandbox::AReloadableClass.respond_to?(:reloadable?)
|
||||
end
|
||||
|
@ -76,7 +70,6 @@ class ReloadableTest < Test::Unit::TestCase
|
|||
)
|
||||
non_reloadables = %w(
|
||||
ANonReloadableSubclass
|
||||
AModuleIncludingReloadable
|
||||
OnlySubclassesReloadable
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue