Module.nesting for anonymous modules?

J

James Coglan

[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?
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top