In my rails app I’ve written (with not so many chars) this:
if module_or_str_or_sym == controller.class.to_s.split('::')
I had thought about this:
if eval(module_or_str_or_sym).const_defined? controller.class
but for obvious reasons abandoned it. (1. it doesn’t work
(controller.class is not a string). 2. eval seems like a bad idea.)
This got me wishing for a few things:
to_const method def for Sting and Symbol instead of
() A way to traverse the nesting of a given class/module e.g.
controller.class.nesting # => [MyModule, MyController]
(*) A method to determine if a class/module is nested in another
class/module. For instance
I’d like to know if anyone else thinks this would be useful or already
has a solution.