mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
AS guide: documents Class#subclasses
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user