Skip to content

Instantly share code, notes, and snippets.

@mikebaldry
Created November 15, 2011 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mikebaldry/1366593 to your computer and use it in GitHub Desktop.
Save mikebaldry/1366593 to your computer and use it in GitHub Desktop.
find subclasses
def self.all
results = []
ObjectSpace.each_object(Class) do |c|
(results << c) if c.ancestors.include?(PullSource) && c != PullSource
end
results
end
@mikebaldry
Copy link
Author

ruby-1.9.2-p290 :017 > PhPullSource.ancestors
=> [PhPullSource, PullSource, Object, ActiveSupport::Dependencies::Loadable, PP::ObjectMixin, Mongoid::Extensions::Object::Yoda, Mongoid::Extensions::Object::Substitutable, Mongoid::Extensions::Object::Reflections, Mongoid::Extensions::Object::Checks, JSON::Ext::Generator::GeneratorMethods::Object, Kernel, BasicObject]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment