From 4eec5f4fbb995ce665cb82367cc3965e74147b19 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Wed, 14 Mar 2007 23:27:28 +0000 Subject: Update Dependencies to ignore constants inherited from ancestors. Closes #6951. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6426 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_support/core_ext/module/introspection.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/module/introspection.rb b/activesupport/lib/active_support/core_ext/module/introspection.rb index 0cd0d1ff2c..36481927aa 100644 --- a/activesupport/lib/active_support/core_ext/module/introspection.rb +++ b/activesupport/lib/active_support/core_ext/module/introspection.rb @@ -18,4 +18,18 @@ class Module parents << Object unless parents.include? Object parents end + + # Return the constants that have been defined locally by this object and not + # in an ancestor. This method may miss some constants if their definition in + # the ancestor is identical to their definition in the receiver. + def local_constants + inherited = {} + ancestors.each do |anc| + next if anc == self + anc.constants.each { |const| inherited[const] = anc.const_get(const) } + end + constants.select do |const| + ! inherited.key?(const) || inherited[const].object_id != const_get(const).object_id + end + end end -- cgit v1.2.3