From d920b5654e30ed10caf56bab6198fbd99fecd12d Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 14 Apr 2014 04:16:38 -0700 Subject: Add unload_module method. --- dinobot.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dinobot.rb b/dinobot.rb index 866396e..f5ea364 100644 --- a/dinobot.rb +++ b/dinobot.rb @@ -123,5 +123,22 @@ module Dinobot puts "== Failed to load module: #{mod} (#{e.message})" end end + + def unload_module(mod) + mod = mod.downcase.intern + puts "== Unloading module: #{mod}" + + unless @modules.has_key?(mod) + puts "== Failed to unload module: #{mod} (module not loaded)" + return + end + + @modules.delete(mod) + + Dinobot.send( + :remove_const, + Dinobot.constants.find { |x| x.downcase == mod } + ) + end end end -- cgit v1.2.3-70-g09d2