aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-01-12 12:17:24 -0800
committerXavier Noria <fxn@hashref.com>2012-01-12 12:17:35 -0800
commit04df7bb02c8a267ec7cd1c20ba20a49a24cffb2f (patch)
treefeeaaada1aef0e1055bd1626274dfd7a49d0e29d /activesupport/lib
parent3c64548859a9e778bc6f5b0bdb796dc1b5136c3d (diff)
downloadrails-04df7bb02c8a267ec7cd1c20ba20a49a24cffb2f.tar.gz
rails-04df7bb02c8a267ec7cd1c20ba20a49a24cffb2f.tar.bz2
rails-04df7bb02c8a267ec7cd1c20ba20a49a24cffb2f.zip
deprecates Module#local_constant_names
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/module/introspection.rb14
-rw-r--r--activesupport/lib/active_support/dependencies.rb4
2 files changed, 14 insertions, 4 deletions
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 <tt>local_constants</tt>.
+ # *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