From: Robert Klemme Date: 2003-04-24T01:20:39+09:00 Subject: Re: Module inclusion at runtime... I read you post several times over but I'm still not sure, whether I got it completely. "Hadmut Danisch" schrieb im Newsbeitrag news:b86atp$1iq$04$1@news.t-online.com... > Hi, > > I want to have some nested structure of modules, > > basically something like > > > module Monday > autoload :Morning, "morning" > > module XYZ > ... > end > end > > > > which works without problems. > in morning.rb the module is written as > > module Morning > ... > end > > and automatically becomes Monday::Morning. > without the need to ever mention "Monday" in the source > file. > > But now I want to include the module XYZ into > Morning without writing > include Monday::XYZ > because I do not want to write Morning in a way that > it fits into Monday only. You can't. It's locigally impossible since XYZ is part of Monday. Everybody who wants to use XYZ must know about Monday. Apart from that, nesting XZY twice into Monday (once directly and then via Monday) is at least odd. Maybe you let us know what you are trying to accomplish and then somebody can come up with a more appropriate solution. > How can the module Morning figure out at runtime > which parent module has just included it? For this maybe something like this works, although I don't really like it: a = aModule.name.split('::') a.pop parentName = a.join('::') Regards Robert