Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Module.nesting for anonymous modules? (http://www.velocityreviews.com/forums/t854191-module-nesting-for-anonymous-modules.html)

James Coglan 11-15-2008 10:16 AM

Module.nesting for anonymous modules?
 
[Note: parts of this message were removed to make it a legal post.]

Hi list,

I'm trying to get a reference to the module that a method is defined in,
problem being that the module is generated dynamically so is not part of the
AST.

foo = Module.new do
def m
Module.nesting
end
end
=> #<Module:0x28879c4>

c = Class.new { include foo }
=> #<Class:0x287164c>

c.new.m
=> []

Is there any way for a method defined like this to get a reference to its
containing module?



All times are GMT. The time now is 09:37 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.