From aa82bdf92953824fd35db4a734bf6effa8de3329 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 11 Feb 2010 23:41:16 +0100 Subject: moves Class#reachable? to Module#reachable?, bases implementation on anonymous? and constantize, and adds test coverage --- activesupport/lib/active_support/core_ext/module/reachable.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 activesupport/lib/active_support/core_ext/module/reachable.rb (limited to 'activesupport/lib/active_support/core_ext/module') 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 -- cgit v1.2.3