From: Robert Klemme Date: 2013-01-04T20:07:56+09:00 Subject: Re: Require a ruby project to automatically include the modules in classes defined in the same .rb file On Fri, Jan 4, 2013 at 6:08 AM, Josh Cheek wrote: > O.o You have 3000 classes? I can't imagine such a project. That's not overly large for a reasonable sized project I'd say. > Anyway, there are ways you could do this, but they would require the > blackest of magics (hooking into require or using set_trace_func, and then > parsing the files in some manner to identify the namespaces around the > classes so you can locate them to include the module). Really, what Robert > suggested makes the most sense, include it into Object. Or, even better, make it a "function", i.e. define it at top level and pass the object as argument. > But honestly, with a project that big, I think I'd want everything to be > absolutely explicit all the time, anyway. +1 > 3000 is a huge number, though. Are you generating code? Why do all of your > classes need to include a colourization module? I very rarely need any such > thing, perhaps there is a deeper issue here which would be more useful to > discuss than this idea (which is a highly questionable one anyway). Yes, that might well be. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/