From: Yoann Guillot Date: 2006-04-20T02:13:10+09:00 Subject: Re: Nested scopes Pit Capitain wrote: > > >module Foo > > def self.bar > > puts "bar!" > > end > > > > bar # works > > > > class Baz > > # bar # doesn't work > > # self.bar # doesn't work > > Foo.bar # need to know the module name > > Module.nesting[ 1 ].bar > > > end > >end > Thanks, Module.nesting[-2] is quite close of what i need. However i does not work in class Foo::Baz end In this case i can use Robert Klemme's Module.outer, but this one doesn't work with anonymous modules :) In my case i'll just use this workaround, but i still think that's odd. I found something close that behaves like i though it would, it's constants: class Parent PM = 'parent' P = 'parent' end module Mod PM = 'module' M = 'module' class Foo < Parent puts M # => 'module' puts P # => 'parent' puts PM # => 'module' end end where there is still the problem of class Mod::Foo puts M # NameError: uninitialized constant end Why is there a difference in the lookup path for constants Vs methods ? Yoann