From: "David A. Black" Date: 2005-05-05T04:21:21+09:00 Subject: Re: [RCR] Object#inside_metaclass? Hi -- > it's sort hard to show in a little code but __logically__ we end up > with something like (greatly simplified) > > class C > > @trait_defaults = { > 'class' => { 'a' => 'default_value' }, > 'instance' => { 'a' => 'default_value' }, > } > > def C::a (Just out of curiosity: do you mean to depart from the usual C.a here? And why? :-) > @a = @trait_defaults['class']['a'] unless defined? @a > @a > end > > def a > @a = @trait_defaults['instance']['a'] unless defined? @a > @a > end > end > > so i need to know, at the point of definition if we're inside a > metaclass to generate the code slightly differently. all the above > is for explanation only and is nothing like real code. I understand the not real code point, but still, it's showing something I can't quite follow, namely the @trait_defaults instance variable in the instance method definition (def a). Do you mean this to refer to the class's instance variable? I'm also not sure where inside_metaclass? would go here. Can you rewrite it into pseudo-code looking how it would look if that method existed? David -- David A. Black dblack@wobblini.net