From: Robert Klemme Date: 2008-03-20T02:56:46+09:00 Subject: Re: Parametric module or injecting code via class method? 2008/3/18, Trans : > > On Mar 18, 12:59 pm, "Sean O'Halpin" wrote: > > > True enough. As I said, I'm only surmising what Trans is after. I'm > > not criticising your response to the concrete example (after all, > > it is both pragmatic and to the point). Rather, I'm taking the > > question Trans posed as an opportunity to discuss what I consider best > > practice in the more general case. > > I'd like to present another example --a simpler one in a sense, of > direct extension vs. using modules. I will leave out most the code for > brevity sakes but consider, but here is an example where I took code > that was straight core extensions and "modulized" it: > > # -- random.rb 100+ lines Did you say "brevity"? LOL > Other Ruby coder's might look at this and think, "clever". I look at > it and think, "obfuscated". First off there is Kernel, b/c of the > double module inclusion problem it can't participate in the whole > "clever" affair. Then there is Self and the included callback hack to > get the class-level methods in there. And on top of it all, there is > the simple fact that I had to create and include a bunch of new > modules and all the overhead that comes with them -- when all I want > to do add a few methods to the core classes/modules. To throw in a > little irony as well, the main reason I even bothered to do this, was > not to help avoid method clash (a fairly unavoidable problem really), > but to get better results for RDoc --and that fact really makes me > sick. Indeed. It sounds rather RDoc should be fixed instead of code tweaked to get desired results. Kind regards robert -- use.inject do |as, often| as.you_can - without end