From: itsme213 Date: 2005-01-30T02:41:24+09:00 Subject: Run-time parameterized modules - ruby style? I think I want to use this design in a few places in my code, to write a single module that can be adapted to different needs: module M def self.[](params) create new module populate using params and (M or ) return new module end end class A include M[p1, p2] end Is this reasonable Ruby style? Have others found uses for this? If the generated module did not include M, what would be a good way of keeping the instantiated M[param] in sync with changes in M? e.g. new methods are added to M, or an M method is re-defined? If this is still roughly within the Ruby way, would it be reasonable style to use this in multi-class modules, as follows: module M module Mx...end module My...end def self.[] (x,y) end module Mine class A...end class B...end include M[p1, p2] # effectively same as # class A; include M::Mx[p1] # class B; include M::My[p2] end Thanks.