From 60ee4632925ad75c7d5de2b99ec0267d5a9496bb Mon Sep 17 00:00:00 2001 From: Dmitry Kim Date: Fri, 14 Dec 2007 21:33:38 +0000 Subject: * (registry) dup() the default on return --- lib/rbot/registry.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/rbot/registry.rb b/lib/rbot/registry.rb index cf27290a..41f9747f 100644 --- a/lib/rbot/registry.rb +++ b/lib/rbot/registry.rb @@ -191,17 +191,16 @@ class Bot debug ee end end - return @default + return default end end # lookup a key in the registry def [](key) - return @default unless File.exist?(@filename) - if registry.has_key?(key) + if File.exist?(@filename) && registry.has_key?(key) return restore(registry[key]) else - return @default + return default end end @@ -216,6 +215,10 @@ class Bot @default = default end + def default + @default && (@default.dup rescue default) + end + # just like Hash#each def each(&block) return nil unless File.exist?(@filename) @@ -274,7 +277,7 @@ class Bot # delete a key from the registry def delete(key) - return @default unless File.exist?(@filename) + return default unless File.exist?(@filename) return registry.delete(key) end -- cgit v1.2.3