From 04df7bb02c8a267ec7cd1c20ba20a49a24cffb2f Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 12 Jan 2012 12:17:24 -0800 Subject: deprecates Module#local_constant_names --- .../lib/active_support/core_ext/module/introspection.rb | 14 ++++++++++++-- activesupport/lib/active_support/dependencies.rb | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/module/introspection.rb b/activesupport/lib/active_support/core_ext/module/introspection.rb index 1893a9cfa6..743db47bac 100644 --- a/activesupport/lib/active_support/core_ext/module/introspection.rb +++ b/activesupport/lib/active_support/core_ext/module/introspection.rb @@ -61,9 +61,19 @@ class Module constants(false) end - # Returns the names of the constants defined locally rather than the - # constants themselves. See local_constants. + # *DEPRECATED*: Use +local_constants+ instead. + # + # Returns the names of the constants defined locally as strings. + # + # module M + # X = 1 + # end + # M.local_constant_names # => ["X"] + # + # This method is useful for forward compatibility, since Ruby 1.8 returns + # constant names as strings, whereas 1.9 returns them as symbols. def local_constant_names + ActiveSupport::Deprecation.warn('Module#local_constant_names is deprecated, use Module#local_constants instead', caller) local_constants.map { |c| c.to_s } end end diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index e121e452a3..2c5950edf5 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -105,7 +105,7 @@ module ActiveSupport #:nodoc: next unless mod.is_a?(Module) # Get a list of the constants that were added - new_constants = mod.local_constant_names - original_constants + new_constants = mod.local_constants - original_constants # self[namespace] returns an Array of the constants that are being evaluated # for that namespace. For instance, if parent.rb requires child.rb, the first @@ -133,7 +133,7 @@ module ActiveSupport #:nodoc: namespaces.map do |namespace| module_name = Dependencies.to_constant_name(namespace) original_constants = Dependencies.qualified_const_defined?(module_name) ? - Inflector.constantize(module_name).local_constant_names : [] + Inflector.constantize(module_name).local_constants : [] watching << module_name @stack[module_name] << original_constants -- cgit v1.2.3