From: Martin DeMello Date: 2002-04-20T05:09:48+09:00 Subject: Re: Replacing groups of methods: How would *you* do this? Hal E. Fulton wrote: > Suppose I have a class where I consider > a number of methods "pluggable" or > "disposable." (If you're curious, these are > UI-oriented; I'm writing an app with alternate > user interfaces.) > At first I thought: I'll make a module with the > methods in it, then include it at runtime if/when > I choose to. > But then I realized that module instance methods > don't replace class instance methods. Hmm. > So I thought: I can write replacement methods > in the same class and put them in separate > files which I then include. > But I don't really want to use separate files. > What do you think? How about using alias to swap in and out sets of methods, rather than actually replacing them? Something like def swapin(i) ["method1","method2"].each {|m| eval "alias #{m} #{methodset[i][m]}" } end -- Martin DeMello