From: Matt Mower Date: 2008-02-11T18:36:38+09:00 Subject: Re: alias_method and initialize On 2/9/08, Leon Bogaert wrote: > I tried something new: > > http://pastie.caboo.se/149810 > > But I get an error. Does anyone know why initialize_with_extras isn't > defined at that point? > Your problem, as I understand it, is that included is called in the context of the class Test and not any of it's instances. Try this (http://pastie.caboo.se/150269): module Extras def initialize_with_extras initialize_without_extras #Do it! @tests[2] = 'ok too!' end def self.included( base ) base.__send__( :alias_method, :initialize_without_extras, :initialize ) base.__send__( :alias_method, :initialize, :initialize_with_extras ) end end Output: ["ok!", "ok too!"] It uses the "included" method in the module to amend the class and setup the initialize alias chain that you need. Hope this helps. Regards, Matt. -- Matt Mower :: http://matt.blogs.it/