提交 9d0d6f7d 编写于 作者: J Jeremy Kemper

Clear const references all at once

上级 fd1a5041
......@@ -479,23 +479,26 @@ def load_missing_constant(from_mod, const_name)
def remove_unloadable_constants!
autoloaded_constants.each { |const| remove_constant const }
autoloaded_constants.clear
references.each {|k,v| v.clear! }
Reference.clear!
explicitly_unloadable_constants.each { |const| remove_constant const }
end
class Reference
@@constants = Hash.new { |h, k| h[k] = Inflector.constantize(k) }
attr_reader :name
def initialize(name, constant = nil)
@name, @constant = name, constant
def initialize(name)
@name = name.to_s
@@constants[@name] = name if name.respond_to?(:name)
end
def get
@constant ||= Inflector.constantize(@name)
@@constants[@name]
end
def clear!
@constant = nil
def self.clear!
@@constants.clear
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册