From: transfire@... Date: 2006-07-22T01:58:18+09:00 Subject: Re: class_extension and module_extension This is actually pretty interesting. I'm in the midst of deep meta code and I have the situation where I'm creating a sort of DSL for building classes --you know, defining my own attr methods. And then I use that in a module which is to be included into my class. That way I keep these DSL methods out of my class (qua class). Eg. module MetaDSL def foos() @foos ||=[] end def metafoo x foos << x attr_reader "#{x}oo" end end module MetaFoo extend MetaDSL metafoo :f end class Foo include MetaFoo end The problem is that I actaully want #foos to show up in my class (qua class) but not metafoo! How's can I achieve that? In the future there's class_extension, and I suggested module_extiension too, one for propogating and one not (which is which?) So a solution would be: module MetaDSL # lets say class_extension propogates class_extension do def foos() @foos ||=[] end end # and module_extension does not module_extension do def metafoo x foos << x attr_reader "#{x}oo" end end end module MetaFoo include MetaDSL metafoo :f end But uh oh! Now the two methods can't see each other. Well, maybe we can fix by including the returned module of each when invoked without a block: module MetaDSL class_extension do def foos() @foos ||=[] end end include class_extension module_extension do def metafoo x foos << x attr_reader "#{x}oo" end end include module_extension end Will that work? Well, I assume somthing to that effect would. But even so, now I'm looking at this and thinking it got quite complex, when all I really want to do is *control visibility*, much like public, private and protected. But local, single_provision, and propogated (for lack of better terms). T.