From: gwtmp01@... Date: 2006-07-12T00:05:41+09:00 Subject: Re: module private methods inheritance ? On Jul 11, 2006, at 10:21 AM, transfire@gmail.com wrote: > You can skip over ancestors using something like > facet/kernel/as but initialize is a touchy matter --it's not something > one generally defines in a module in the first place. I see this idea mentioned often (avoid initialize in modules). Some modules need initialization, some don't. I don't think it is helpful to generalize beyond that. I often see: module A def foo @foo ||= {} end end which is basically a lazy initialization of @foo by the module instead of: module A def initialize @foo = {} end end class B def initialize super # init for B here end end You can use Module#included to handle class/module level initialization but I sometimes wish there was a well-defined instance initialization hook for included modules instead of relying on the appropriate use of super() within initialize(). I'm not sure what it would look like though, maybe: module M def self.instantiated(x) x.initialize_M end def initialize_M #initialization for M goes here end end Presumably Class#new would trigger Module.instantiated for all included modules in some well defined order (appearence in ancestors list?). These seems kind of inelegant though. There must be a better solution. Or maybe it is a solution looking for a problem. Gary Wright