From: Phrogz Date: 2007-10-16T08:00:03+09:00 Subject: Re: Override methods from a module On Oct 15, 4:51 pm, Phrogz wrote: > Note that this requires calling super in the initialize of the source > class, which may break other ancestor modules/classes expecting > different arguments to be passed in. Ideally the module would latch > onto and wrap the initialize method itself when included in the class, > but I was too lazy to do that. Here's a slightly cleaner version, showing that you can fully wrap the class method. module Foo def initialize( *args ) self.extend Foo::Stuff end module Stuff def bar puts "before class" super puts "after class" end end end class Bar include Foo def initialize super end def bar puts "in class" end end goof = Bar.new goof.bar #=> before class #=> in class #=> after class