From: Erik Veenstra Date: 2006-07-22T23:25:01+09:00 Subject: Re: Meta-Meta-Programming, revisited > Sorry, I misprepresnted what I meant. Use "aModule" instead > of "Module". -- You created a special method: > #wrap_module_method for doing #wrap_method external to the a > module/class, but you could just make it public (or use > send): > > aModule.wrap_method Wrong!... ;] The receiver of wrap_method is *always* a module/class. When wrapping an instance method, with wrap_method, the receiver is a module. When wrapping a module method, with wrap_module_method, the receiver is the singleton class of that module. So, you should write aModule.meta_class.wrap_method (using Why's little meta library...). Or, in default Ruby: class << aModule self end.instance_eval wrap_method(method_name){...} end I don't want to see this in regular, every day Ruby code. That's why I came up with this wrap_module_method and this stupid Module argument thing. ;] Kind of shortcuts... > ...becuase then hwy use def at all, alwasy use > #wrap_method... ;] > > * When wrapping methods in both the class and the superclass, > > going up and down, you can't (at wrap-time) determine the > > order in which the blocks are to be executed (at run-time). > > If I run the code below with your wrap_method (after removing > > the "method does not exist" check), this :wrap_Foo is gone! > > It's not what _I_ expected... ;] (See [1] for a more > > complicated example. I'll try to make a diagram.) > > Owww! Nice catch. I hadn't though of that. ;] > > It's complicated stuff... I tried to hide this complexity > > for the user, by providing a clean interface (wrap_method) > > and an even cleaner interface (pre_condition). I hope you > > find them easy to use. > > Indeed. I'm going to work with this see what I can incoprate > into Facets', if that's cool with you. Sure. Everybody is free to copy the code and use it for whatever reason. If you make money with it, please call me... gegroet, Erik V. - http://www.erikveen.dds.nl/