From 72c83893a5221c1054347bda2be09ee4b7f3a897 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 11 Feb 2010 00:20:37 +0100 Subject: AS guide: documents Class#subclasses --- .../source/active_support_core_extensions.textile | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'railties/guides/source/active_support_core_extensions.textile') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index da22b4113d..f58bed54d7 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -977,6 +977,39 @@ If for whatever reason an application loads the definition of a mailer class and NOTE: Defined in +active_support/core_ext/class/delegating_attributes.rb+. +h4. Descendants + +h5. +subclasses+ + +The +subclasses+ method returns the names of all the anonymous or reachable descendants of its receiver as an array of strings: + + +class C; end +C.subclasses # => [] + +Integer.subclasses # => ["Bignum", "Fixnum"] + +module M + class A; end + class B1 < A; end + class B2 < A; end +end + +module N + class C < M::B1; end +end + +M::A.subclasses # => ["N::C", "M::B2", "M::B1"] + + +The order in which these class names are returned is unspecified. + +See also +Object#subclasses_of+ in "Extensions to All Objects FIX THIS LINK":FIXME. + +WARNING: This method is redefined in some Rails core classes. + +NOTE: Defined in +active_support/core_ext/class/subclasses.rb+. + h3. Extensions to +String+ h4. Output Safety -- cgit v1.2.3