AS guide: documents Class#subclasses

This commit is contained in:
Xavier Noria
2010-02-11 00:20:37 +01:00
parent 6a395c68d2
commit 72c83893a5

View File

@@ -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:
<ruby>
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"]
</ruby>
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