Skip to content

Commit

Permalink
Undo accidental commit
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5303 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
seckar committed Oct 14, 2006
1 parent 4257fd6 commit 2049313
Showing 1 changed file with 16 additions and 42 deletions.
58 changes: 16 additions & 42 deletions activesupport/lib/active_support/dependencies.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ module Dependencies #:nodoc:
mattr_accessor :autoloaded_constants mattr_accessor :autoloaded_constants
self.autoloaded_constants = [] self.autoloaded_constants = []


# An array of constant names that need to be unloaded on every request. Used
# to allow arbitrary constants to be marked for unloading.
mattr_accessor :explicitly_unloadable_constants
self.explicitly_unloadable_constants = []

# Set to true to enable logging of const_missing and file loads # Set to true to enable logging of const_missing and file loads
mattr_accessor :log_activity mattr_accessor :log_activity
self.log_activity = false self.log_activity = false
Expand All @@ -65,7 +60,7 @@ def associate_with(file_name)
def clear def clear
log_call log_call
loaded.clear loaded.clear
remove_unloadable_constants! remove_autoloaded_constants!
end end


def require_or_load(file_name, const_path = nil) def require_or_load(file_name, const_path = nil)
Expand Down Expand Up @@ -257,12 +252,21 @@ def load_missing_constant(from_mod, const_name)
end end
end end


# Remove the constants that have been autoloaded, and those that have been # Remove the constants that have been autoloaded.
# marked for unloading. def remove_autoloaded_constants!
def remove_unloadable_constants! until autoloaded_constants.empty?
autoloaded_constants.each { |const| remove_constant const } const = autoloaded_constants.shift
autoloaded_constants.clear next unless qualified_const_defined? const
explicitly_unloadable_constants.each { |const| remove_constant const } names = const.split('::')
if names.size == 1 || names.first.empty? # It's under Object
parent = Object
else
parent = (names[0..-2] * '::').constantize
end
log "removing constant #{const}"
parent.send :remove_const, names.last
true
end
end end


# Determine if the given constant has been automatically loaded. # Determine if the given constant has been automatically loaded.
Expand All @@ -272,21 +276,6 @@ def autoloaded?(desc)
return autoloaded_constants.include?(name) return autoloaded_constants.include?(name)
end end


# Will the provided constant descriptor be unloaded?
def will_unload?(const_desc)
autoloaded?(desc) ||
explicitly_unloadable_constants.include?(const_desc.to_constant_name)
end

# Mark the provided constant name for unloading. This constant will be
# unloaded on each request, not just the next one.
def mark_for_unload(const_desc)
name = const_desc.to_constant_name
unless explicitly_unloadable_constants.include? name
explicitly_unloadable_constants << name
end
end

class LoadingModule class LoadingModule
# Old style environment.rb referenced this method directly. Please note, it doesn't # Old style environment.rb referenced this method directly. Please note, it doesn't
# actualy *do* anything any more. # actualy *do* anything any more.
Expand All @@ -311,21 +300,6 @@ def to_constant_name(desc)
end end
end end


def remove_constant(const)
return false unless qualified_const_defined? const

names = const.split('::')
if names.size == 1 || names.first.empty? # It's under Object
parent = Object
else
parent = (names[0..-2] * '::').constantize
end

log "removing constant #{const}"
parent.send :remove_const, names.last
return true
end

def log_call(*args) def log_call(*args)
arg_str = args.collect(&:inspect) * ', ' arg_str = args.collect(&:inspect) * ', '
/in `([a-z_\?\!]+)'/ =~ caller(1).first /in `([a-z_\?\!]+)'/ =~ caller(1).first
Expand Down

0 comments on commit 2049313

Please sign in to comment.