diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-06-05 22:02:49 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-06-05 22:08:02 -0700 |
commit | 9d0d6f7d261a14def6afd17568b8c8aa7c33d0b3 (patch) | |
tree | 117ef5ab5b89a0aeb1c2e8b8e2e6e5a320a9f5dc | |
parent | fd1a5041362f5e65b813b7938d477143bd82de40 (diff) | |
download | rails-9d0d6f7d261a14def6afd17568b8c8aa7c33d0b3.tar.gz rails-9d0d6f7d261a14def6afd17568b8c8aa7c33d0b3.tar.bz2 rails-9d0d6f7d261a14def6afd17568b8c8aa7c33d0b3.zip |
Clear const references all at once
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 5091abc3a4..16c3bc1142 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -479,23 +479,26 @@ module ActiveSupport #:nodoc: 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 |