From d610295cf3bea55d88db44fe573ca35cd5728a34 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 31 May 2009 15:52:16 +0200 Subject: AS guide: explains Class#subclasses --- .../guides/source/active_support_overview.textile | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'railties/guides/source/active_support_overview.textile') diff --git a/railties/guides/source/active_support_overview.textile b/railties/guides/source/active_support_overview.textile index 4b3e533e7a..659e4cdd50 100644 --- a/railties/guides/source/active_support_overview.textile +++ b/railties/guides/source/active_support_overview.textile @@ -9,13 +9,11 @@ By referring to this guide you will learn: endprologue. -h3. Extensions to +Kernel+ +h3. Extensions to All Objects -... +h4. +blank?+ and +present?+ -h3. Extensions to +Object+ -... h3. Extensions to +Module+ @@ -108,6 +106,34 @@ end If for whatever reason an application loads the definition of a mailer class and after that sets +ActionMailer::Base.delivery_method+, the mailer class will still see the new value. In addition, the mailer class is able to change the +delivery_method+ without affecting the value in the parent using its own inherited class attribute writer. +h4. Descendants + +The method +Class#subclasses+ returns the names of all subclasses of a given class as an array of strings. That comprises not only direct subclasses, but all descendants down the hierarchy: + + +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 unespecified. + +See also +Object#subclasses_of+ in "Extensions to All Objects FIX THIS LINK":FIXME. + + h3. Extensions to +NilClass+ ... -- cgit v1.2.3