Last Updated: February 25, 2016
·
644
· kcurtin

ObjectSpace in Ruby

If you want to gather information about a bunch of objects in Ruby, you can iterate through them and ask. For example, to find all classes that have Enumerable mixed in you can do this:

ObjectSpace.each_object(Class).select { |e| e.ancestors.include?(Enumerable) }"