John Lam wrote:
> Here is a nested class definition:
> 
> class A
>  class B
>  end
> end
> 
> Now, if I have a reference to class B from somewhere:
> 
> def get_reference
>  A::B
> end
> 
> reference_b = get_reference
> 
> How can I get a reference to the enclosing class A?
> 
> I can't do this by symbol lookup since class A (and B for that matter)
> are anonymous. Am I going to have to explicitly create a
> back-reference to the enclosing class at the time that I create class
> B?
> 
> Thanks
> -John
> http://www.iunknown.com

class A
   class B
     @nesting = Module.nesting
     class << self; attr_reader :nesting; end
   end
end

p A::B.nesting  # ==> [A::B, A]

However, you say the classes are anonymous. How are you getting B under
the scope of A in that case?

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407