Skip to content
This repository

Class.__subclasses__ was removed from Rubinius #166

Closed
wants to merge 1 commit into from

1 participant

John Firebaugh
John Firebaugh

https://github.com/evanphx/rubinius/issues/issue/11
evanphx/rubinius@2fccbb5

This commit removes its use in Rails. Besides removing code which is now dead on all existing interpreters, it's probably not good practice to rely on the behavior of a non-standard extension.

John Firebaugh

Committed cc446ee

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
54  activesupport/lib/active_support/core_ext/class/subclasses.rb
@@ -2,49 +2,35 @@
2 2
 require 'active_support/core_ext/module/reachable'
3 3
 
4 4
 class Class #:nodoc:
5  
-  # Rubinius
6  
-  if defined?(Class.__subclasses__)
7  
-    alias :subclasses :__subclasses__
  5
+  begin
  6
+    ObjectSpace.each_object(Class.new) {}
8 7
 
9 8
     def descendants
10 9
       descendants = []
11  
-      __subclasses__.each do |k|
12  
-        descendants << k
13  
-        descendants.concat k.descendants
  10
+      ObjectSpace.each_object(class << self; self; end) do |k|
  11
+        descendants.unshift k unless k == self
14 12
       end
15 13
       descendants
16 14
     end
17  
-  else # MRI
18  
-    begin
19  
-      ObjectSpace.each_object(Class.new) {}
20  
-
21  
-      def descendants
22  
-        descendants = []
23  
-        ObjectSpace.each_object(class << self; self; end) do |k|
24  
-          descendants.unshift k unless k == self
25  
-        end
26  
-        descendants
27  
-      end
28  
-    rescue StandardError # JRuby
29  
-      def descendants
30  
-        descendants = []
31  
-        ObjectSpace.each_object(Class) do |k|
32  
-          descendants.unshift k if k < self
33  
-        end
34  
-        descendants.uniq!
35  
-        descendants
  15
+  rescue StandardError # JRuby
  16
+    def descendants
  17
+      descendants = []
  18
+      ObjectSpace.each_object(Class) do |k|
  19
+        descendants.unshift k if k < self
36 20
       end
  21
+      descendants.uniq!
  22
+      descendants
37 23
     end
  24
+  end
38 25
 
39  
-    # Returns an array with the direct children of +self+.
40  
-    #
41  
-    #   Integer.subclasses # => [Bignum, Fixnum]
42  
-    def subclasses
43  
-      subclasses, chain = [], descendants
44  
-      chain.each do |k|
45  
-        subclasses << k unless chain.any? { |c| c > k }
46  
-      end
47  
-      subclasses
  26
+  # Returns an array with the direct children of +self+.
  27
+  #
  28
+  #   Integer.subclasses # => [Bignum, Fixnum]
  29
+  def subclasses
  30
+    subclasses, chain = [], descendants
  31
+    chain.each do |k|
  32
+      subclasses << k unless chain.any? { |c| c > k }
48 33
     end
  34
+    subclasses
49 35
   end
50 36
 end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.