On 21/10/2009, at 9:13 AM, Sven Schott wrote:
> I did have a look at that but that is to retrieve the modules nested
> from the location of the call. I need the top n-parent module of a
> particular object (any object), so I don't thinks this would be
> useful in this particular case.
>
> Unless you wanted to extend the object on the fly to do it. :)
Well, that is a perfectly Ruby-esque way of doing things. :-)
I would have thought it was easy, too... but it really is difficult,
isn't it?!
Obvious things like this:
thing = Some::Thing.new
def thing.get_nesting
Module.nesting
end
thing.get_nesting
don't work, because it seems to get the "point of call" from outside
the class.
I tried playing around with class_eval, eigenclasses, and the
'included' callback an they're all a bit fruitless. I think it really
might be limited to only the "currently evaluated bit of code"...
which would suck if true.
Pretty frustrating.
Dave Thomas from PragProg might know... I've watched his screencasts
on Ruby Metaprogramming about 3 or 4 times now, and although I'm
hooked, my head hurts whenever I try to do any of this stuff... :-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
or Rails Oceania" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en
-~----------~----~----~----~------~----~------~--~---