dynamic loading and unloading of module

ulli bei Unity <[email protected]> Thu, 15 Aug 2019 10:50:25 +0200
Newsgroups gmane.comp.lang.ruby.general
Message-ID <[email protected]>
Hi,

I want to load and remove dynamically Module in an application. Removing 
is possible, but

I am not able to reload it. Is there any way to do it?

Is it even recommendable to do something like this?

Ulli




module Mod
   def foo
     puts "fooing"
   end
end

module Modd
   def foo
     puts "fooing2"
   end
end


class C
   include Mod

   def self.remove_module(m)
     m.instance_methods.each{|m| undef_method(m)}
   end

   def self.addModul m
         include m
     end
end

c = C.new
c.foo
C.remove_module(Mod)

C.addModul(Modd)
c.foo


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>