Skip to content

Instantly share code, notes, and snippets.

@dmajda
Created July 11, 2012 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmajda/3089258 to your computer and use it in GitHub Desktop.
Save dmajda/3089258 to your computer and use it in GitHub Desktop.
def check_classes
# Get list of all subclasses of Scanny::Checks::Check.
classes = []
ObjectSpace.each_object(Class) do |klass|
classes << klass if klass < Scanny::Checks::Check
end
# Filter out classes that are a superclass of some other class in the list.
# This way only "leaf" classes remain.
classes.reject do |klass|
classes.any? { |c| c < klass }
end
classes.map(&:new)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment