From 5f4d121798b5045503e9201ae11ead82f3087c25 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 27 Sep 2007 11:01:20 +0000 Subject: Dependencies Ruby 1.9 compat git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7660 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/dependencies.rb | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 828015d2f3..9a2c933ab5 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -229,10 +229,10 @@ module Dependencies #:nodoc: from_mod = Object end end - + # If we have an anonymous module, all we can do is attempt to load from Object. - from_mod = Object if from_mod.name.empty? - + from_mod = Object if from_mod.name.blank? + unless qualified_const_defined?(from_mod.name) && from_mod.name.constantize.object_id == from_mod.object_id raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!" end @@ -392,11 +392,9 @@ module Dependencies #:nodoc: end end -protected - # Convert the provided const desc to a qualified constant name (as a string). # A module, class, symbol, or string may be provided. - def to_constant_name(desc) + def to_constant_name(desc) #:nodoc: name = case desc when String then desc.starts_with?('::') ? desc[2..-1] : desc when Symbol then desc.to_s @@ -406,10 +404,10 @@ protected else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}" end end - - def remove_constant(const) + + def remove_constant(const) #:nodoc: return false unless qualified_const_defined? const - + const = $1 if /\A::(.*)\Z/ =~ const.to_s names = const.to_s.split('::') if names.size == 1 # It's under Object @@ -417,12 +415,13 @@ protected else parent = (names[0..-2] * '::').constantize end - + log "removing constant #{const}" parent.instance_eval { remove_const names.last } return true end - + +protected def log_call(*args) arg_str = args.collect(&:inspect) * ', ' /in `([a-z_\?\!]+)'/ =~ caller(1).first -- cgit v1.2.3