aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2007-03-14 23:27:28 +0000
committerNicholas Seckar <nseckar@gmail.com>2007-03-14 23:27:28 +0000
commit4eec5f4fbb995ce665cb82367cc3965e74147b19 (patch)
treeb44ff95dc30372057dc47699423bad0c35c0a4b0 /activesupport/lib/active_support/core_ext
parentbbcfb9b625c4ed471fcf7c827b700ccb025e7dd9 (diff)
downloadrails-4eec5f4fbb995ce665cb82367cc3965e74147b19.tar.gz
rails-4eec5f4fbb995ce665cb82367cc3965e74147b19.tar.bz2
rails-4eec5f4fbb995ce665cb82367cc3965e74147b19.zip
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
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/module/introspection.rb14
1 files changed, 14 insertions, 0 deletions
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