aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/module
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-02-11 23:41:16 +0100
committerXavier Noria <fxn@hashref.com>2010-02-11 23:41:16 +0100
commitaa82bdf92953824fd35db4a734bf6effa8de3329 (patch)
tree257c4719fb2b37a21cdb5a5eeba62f1a5023d2b1 /activesupport/lib/active_support/core_ext/module
parentb8bb54af7ff6652327d99f6a7cf5c96a3f3f876d (diff)
downloadrails-aa82bdf92953824fd35db4a734bf6effa8de3329.tar.gz
rails-aa82bdf92953824fd35db4a734bf6effa8de3329.tar.bz2
rails-aa82bdf92953824fd35db4a734bf6effa8de3329.zip
moves Class#reachable? to Module#reachable?, bases implementation on anonymous? and constantize, and adds test coverage
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module')
-rw-r--r--activesupport/lib/active_support/core_ext/module/reachable.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/reachable.rb b/activesupport/lib/active_support/core_ext/module/reachable.rb
new file mode 100644
index 0000000000..443d2c3d53
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/module/reachable.rb
@@ -0,0 +1,10 @@
+require 'active_support/core_ext/module/anonymous'
+require 'active_support/core_ext/string/inflections'
+
+class Module
+ def reachable? #:nodoc:
+ !anonymous? && name.constantize.equal?(self)
+ rescue NameError
+ false
+ end
+end