Skip to content

Instantly share code, notes, and snippets.

@guivinicius
Created September 15, 2011 20:48
Show Gist options
  • Select an option

  • Save guivinicius/1220442 to your computer and use it in GitHub Desktop.

Select an option

Save guivinicius/1220442 to your computer and use it in GitHub Desktop.

Revisions

  1. guivinicius revised this gist Sep 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion test.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    class Parent

    def self.descendants
    ObjectSpace.each_object(Class).find_all { |klass| klass if < Parent }
    ObjectSpace.each_object(Class).find_all { |klass| klass if klass < Parent }
    end

    end
  2. guivinicius created this gist Sep 15, 2011.
    17 changes: 17 additions & 0 deletions test.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    class Parent

    def self.descendants
    ObjectSpace.each_object(Class).find_all { |klass| klass if < Parent }
    end

    end

    class OlderChild < Parent

    end

    class YoungerChild < Parent

    end

    puts Parent.descendants