From: "Kent S." Date: 2004-05-20T23:05:10+09:00 Subject: Re: Include into class after instance is created Use Object#extend instead of include. Cheers, Kent. On May 20, 2004, at 9:48 AM, Brian Schroeder wrote: > Hello, > > it's me again with another question. I want to include a module only > after > having instantiated a class. Something like this > > File: german.rb > Module Index > Title = 'Meine Seite' > end > > File: english.rb > Module Index > Title = 'My Page' > end > > file index.rb: > class Index < Website > def initialize > super > include(Index) > end > end > > where Website requires either german.rb or english.rb. > > But I can't call include as a function. Ruby complains that it is a > private function of class. > > ../index.rb:10:in `initialize': private method `include' called for > Index:Class (NoMethodError) > from ./index.rb:27:in `new' > from ./index.rb:27 > > Is this scheme possible, am I totally on the wrong track or just > missing > something obvious? > > Regards, > > Brian > > -- > Brian Schr�der > http://www.brian-schroeder.de/ >