In article <20030223231845.GA7488 / quasar>,
Timothy Bauscher  <timothy / linuxfromscratch.org> wrote:
>I'm developing a program which needs to dynamically load
>and unload modules, adding the methods of each module to
>a class. ``include'' is giving me trouble.
>
>The following seems logical to me, but "include" isn't
>known inside the method:
>
>class Quinn
>   def quinn_loadModule(modname)
>      load "modules/#{modname}.rb"
>      include #{modname}
>   end
>end
>
>The following also doesn't work as I expected it to.
>Although it executes without error, the methods in
>the module are not extended into the class:
>
>class Quinn < Module
>   def quinn_loadModule(modname)
>      load "modules/#{modname}.rb"
>      include #{modname}
>   end
>end

include is a method on class Module and I believe that Class already 
inherits from Module - I don't think you want Quinn to inherit from 
Module.  To get this to work you'd have to make 'quinn_loadModule' a 
class method, like:

class Quinn 
  def Quinn.loadModule(modname)
    load "modules/#{modname}.rb"
    include #{modname}
  end
end

....I think that should do what you want.  


Phil