On Monday 29 August 2005 2:52 pm, Jon A. Lambert wrote:
> I want to add instance methods to a class at runtine.
>
> $ cat testcmds.rb
> module Bar
>   def hello
>     puts "hello called"
>   end
> end
>
> class Foo
> end
>
> Foo.include(Bar)
>
> Foo.new.hello
>
> $ ruby testcmds.rb
> testcmds.rb:10: private method `include' called for Foo:Class
> (NoMethodError)
>
> How can I do this?

irb(main):013:0* Foo.send(:include, Bar)
=> Foo
irb(main):014:0> Foo.new.hello
hello called


Kirk Haines