diff options
author | Xavier Noria <fxn@hashref.com> | 2010-01-17 00:33:24 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-01-17 00:33:24 +0100 |
commit | 205b4c41b80b0b0ca995ea6a4dbd07757b609f8b (patch) | |
tree | 4db18a952b518092834b289781300f291b9c5268 /railties/guides | |
parent | 043e876676ad49b3b21d8d90465d7e7a8f8fb25a (diff) | |
download | rails-205b4c41b80b0b0ca995ea6a4dbd07757b609f8b.tar.gz rails-205b4c41b80b0b0ca995ea6a4dbd07757b609f8b.tar.bz2 rails-205b4c41b80b0b0ca995ea6a4dbd07757b609f8b.zip |
AS guide: documents Class#reachable?
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index c911cb9c9f..a0b29dc30b 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -703,6 +703,31 @@ See also +Object#remove_subclasses_of+ in "Extensions to All Objects FIX THIS LI NOTE: Defined in +active_support/core_ext/class/removal.rb+. +h4. Reachable Classes + +By definition a class is reachable if its name constantized is defined, and the corresponding constant evaluates to +self+: + +<ruby> +class C; end +C.reachable? # => true + +phantom = Object.send(:remove_const, :C) + +# The class object is orphan now but it still has a name. +phantom.name # => "C" + +# Class name no longer available as a constant. +phantom.reachable? # => nil + +# Let's define a class named "C" again. +class C; end + +# Class name available as a constant, but different class object. +phantom.reachable? # => false +</ruby> + +NOTE: Defined in +active_support/core_ext/class/removal.rb+. + h3. Extensions to +String+ h4. +squish+ |