"Matthias Georgi" <matti_g / gmx.de> schrieb im Newsbeitrag news:opr71j8uur7zr67k / mail.gmx.net... <snip>example code</snip> > Every missing method for a normal String object will be intercepted, > and the object gets extended with a module in the calling environment. > That's actually what we needs. > My own extensions are only used in my modules. > The code above is only a demonstration of the algorithm. > There is a problem left, I cannot pass the strings outside > my module, because other people are expecting the standard > String interface, so the whole thing should be integrated in the > language core without singleton classes, extending only for the > actual method call. If that functionality is only needed inside the module then IMHO there is a much easier way to accomplish this: define functions in a namespace aka define module methods: module Foo def reformat(str) str.gsub!(/^(.*)$/, '[\\1]') str end class Test include Foo def initialize(s);@s=s;end def do_something puts reformat( @s ).length end end end module Bar def reformat(str) str.gsub!(/^(.*)$/, '<<\\1>>') str end class Test include Bar def initialize(s);@s=s;end def do_something puts reformat( @s ).length end end end >> t1 = Foo::Test.new("xx") => #<Foo::Test:0x10177218 @s="xx"> >> t1.do_something 4 => nil >> t2 = Bar::Test.new("xx") => #<Bar::Test:0x1016f700 @s="xx"> >> t2.do_something 6 => nil Regards robert