N
nraychaudhuri
Is there any way I can find all the classes that have been re-opened
in a project?
in a project?
Is there any way I can find all the classes that have been re-opened
in a project?
Is there any way I can find all the classes that have been re-opened
in a project?
2007/8/22 said:Is there any way I can find all the classes that have been re-opened
in a project?
If you don't mind having a trace proc running while you classes are
being loaded you can do this. (You can always set_trace_func(nil) later
on if you want to stop wasting cpu cycles.)
opened = {}
class_tracer = proc do |event, file, line, id, binding, classname|
case event
when "class" # class or module definition
cl = eval("self", binding)
opened[cl] = true
when "c-call"
case id
when :class_eval, :module_eval
cl = eval("self", binding)
opened[cl] = true
end
end
end
set_trace_func(class_tracer)
class Foo
end
class String
end
Array.class_eval {}
p opened.keys # ==> [Foo, Array, String]
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.