From b0edc8dcf2ba2e7f692c68922849234820bacbe0 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 27 Jan 2010 22:09:52 +0100 Subject: AS guide: Class#remove_class has been removed in 44afd785c8e390f47bc5b80e5d94309b6b56a13c --- .../source/active_support_core_extensions.textile | 47 ---------------------- 1 file changed, 47 deletions(-) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 47482ed803..009e571bc4 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -666,53 +666,6 @@ See aso +Object#subclasses_of+, explained in "Extensions to All Objects FIX THIS NOTE: Defined in +active_support/core_ext/class/removal.rb+. -h4. Class Removal - -Roughly speaking, the +remove_class+ method removes the class objects passed as arguments: - - -Class.remove_class(Hash, Dir) # => [Hash, Dir] -Hash # => NameError: uninitialized constant Hash -Dir # => NameError: uninitialized constant Dir - - -More specifically, +remove_class+ attempts to remove constants with the same name as the passed class objects from their parent modules. So technically this method does not guarantee the class objects themselves are not still valid and alive somewhere after the method call: - - -module M - class A; end - class B < A; end -end - -A2 = M::A - -M::A.object_id # => 13053950 -Class.remove_class(M::A) - -M::B.superclass.object_id # => 13053950 (same object as before) -A2.name # => "M::A" (name is hard-coded in object) - - -WARNING: Removing fundamental classes like +String+ can result in really funky behaviour. - -The method +remove_subclasses+ provides a shortcut for removing all descendants of a given class, where "removing" has the meaning explained above: - - -class A; end -class B1 < A; end -class B2 < A; end -class C < A; end - -A.subclasses # => ["C", "B2", "B1"] -A.remove_subclasses -A.subclasses # => [] -C # => NameError: uninitialized constant C - - -See also +Object#remove_subclasses_of+ in "Extensions to All Objects FIX THIS LINK":FIXME. - -NOTE: Defined in +active_support/core_ext/class/removal.rb+. - h4. Reachable Classes By definition a non-anonymous class is reachable if its name constantized is defined, and the corresponding constant evaluates to +self+: -- cgit v1.2.3