summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
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