diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-14 04:16:38 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-04-14 04:16:38 -0700 |
commit | d920b5654e30ed10caf56bab6198fbd99fecd12d (patch) | |
tree | 7832fd7247b8a0dd3c2ef4542fd7e4cf00e34862 /dinobot.rb | |
parent | b507db60c3901ee81a879114982342cddecde017 (diff) | |
download | dinobot-d920b5654e30ed10caf56bab6198fbd99fecd12d.tar.gz dinobot-d920b5654e30ed10caf56bab6198fbd99fecd12d.tar.xz |
Add unload_module method.
Diffstat (limited to 'dinobot.rb')
-rw-r--r-- | dinobot.rb | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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 |