summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitry Kim <dmitry point kim at gmail point com>2007-12-14 21:33:38 +0000
committerDmitry Kim <dmitry point kim at gmail point com>2007-12-14 21:33:38 +0000
commit60ee4632925ad75c7d5de2b99ec0267d5a9496bb (patch)
tree94031d25960db4f48e84f25822cf5d9a45cbcc2b /lib
parentfbc5edf0b5312005f8e9f79e4916e5f35b757647 (diff)
* (registry) dup() the default on return
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/registry.rb13
1 files changed, 8 insertions, 5 deletions
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