aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/class/subclasses.rb
diff options
context:
space:
mode:
authorAlvaro Pereyra <alvaro@xendacentral.com>2012-05-28 02:29:46 -0500
committerAlvaro Pereyra <alvaro@xendacentral.com>2012-05-28 02:29:46 -0500
commit72973a30704894c808836d80a001208c1af39e7c (patch)
treeab84954fed3e67628bb0884b0e4b0376638bc5dc /activesupport/lib/active_support/core_ext/class/subclasses.rb
parent011863673a353c334ddb2c93227dceadc5d7c3b6 (diff)
parent0ad2146ccf45b3a26924e729a92cd2ff98356413 (diff)
downloadrails-72973a30704894c808836d80a001208c1af39e7c.tar.gz
rails-72973a30704894c808836d80a001208c1af39e7c.tar.bz2
rails-72973a30704894c808836d80a001208c1af39e7c.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'activesupport/lib/active_support/core_ext/class/subclasses.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/class/subclasses.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/subclasses.rb b/activesupport/lib/active_support/core_ext/class/subclasses.rb
index 74ea047c24..c2e0ebb3d4 100644
--- a/activesupport/lib/active_support/core_ext/class/subclasses.rb
+++ b/activesupport/lib/active_support/core_ext/class/subclasses.rb
@@ -1,11 +1,11 @@
require 'active_support/core_ext/module/anonymous'
require 'active_support/core_ext/module/reachable'
-class Class #:nodoc:
+class Class
begin
ObjectSpace.each_object(Class.new) {}
- def descendants
+ def descendants # :nodoc:
descendants = []
ObjectSpace.each_object(singleton_class) do |k|
descendants.unshift k unless k == self
@@ -13,7 +13,7 @@ class Class #:nodoc:
descendants
end
rescue StandardError # JRuby
- def descendants
+ def descendants # :nodoc:
descendants = []
ObjectSpace.each_object(Class) do |k|
descendants.unshift k if k < self
@@ -25,7 +25,13 @@ class Class #:nodoc:
# Returns an array with the direct children of +self+.
#
- # Integer.subclasses # => [Bignum, Fixnum]
+ # Integer.subclasses # => [Fixnum, Bignum]
+ #
+ # class Foo; end
+ # class Bar < Foo; end
+ # class Baz < Foo; end
+ #
+ # Foo.subclasses # => [Baz, Bar]
def subclasses
subclasses, chain = [], descendants
chain.each do |k|