summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-02-13 16:36:43 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-02-13 16:36:43 +0100
commit76d4c3ddf2b8327c6eee1d8e246ca60c74fab6b9 (patch)
treef118cd69703f6f87916d32447fac498c7831250e /lib/rbot
parent7ab8fc67ca91322898327aed1a920f5bddbdab90 (diff)
config: allow @bot.config[key]=value constructs
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/config.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/rbot/config.rb b/lib/rbot/config.rb
index 360cba01..5661b3d1 100644
--- a/lib/rbot/config.rb
+++ b/lib/rbot/config.rb
@@ -70,11 +70,13 @@ module Config
@manager.config[@key] = value
@manager.changed = true
@on_change.call(@manager.bot, value) if on_change && @on_change
+ return self
end
def unset
@manager.config.delete(@key)
@manager.changed = true
@on_change.call(@manager.bot, value) if @on_change
+ return self
end
# set string will raise ArgumentErrors on failed parse/validate
@@ -287,9 +289,13 @@ module Config
return false
end
- # TODO should I implement this via Value or leave it direct?
- # def []=(key, value)
- # end
+ def []=(key, value)
+ return @items[key.to_sym].set(value) if @items.has_key?(key.to_sym)
+ if @config.has_key?(key.to_sym)
+ warning _("Unregistered lookup #{key.to_sym.inspect}")
+ return @config[key.to_sym] = value
+ end
+ end
# pass everything else through to the hash
def method_missing(method, *args, &block)