diff options
author | Dmitry Kim <dmitry point kim at gmail point com> | 2007-12-14 21:06:21 +0000 |
---|---|---|
committer | Dmitry Kim <dmitry point kim at gmail point com> | 2007-12-14 21:06:21 +0000 |
commit | fbc5edf0b5312005f8e9f79e4916e5f35b757647 (patch) | |
tree | 7c19afa2058abc170f0a3f7c6f598e458569c01e /lib | |
parent | a4094acbec334dbc9c17abcbff6a87711fc6d78c (diff) |
* (registry) fix the default value handling for non-existent registry files
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/registry.rb | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/lib/rbot/registry.rb b/lib/rbot/registry.rb index cce2b5c8..cf27290a 100644 --- a/lib/rbot/registry.rb +++ b/lib/rbot/registry.rb @@ -191,27 +191,17 @@ class Bot debug ee end end - unless @default.nil? - begin - return Marshal.restore(@default) - rescue - return nil - end - else - return nil - end + return @default end end # lookup a key in the registry def [](key) - return nil unless File.exist?(@filename) + return @default unless File.exist?(@filename) if registry.has_key?(key) return restore(registry[key]) - elsif @default != nil - return restore(@default) else - return nil + return @default end end @@ -223,7 +213,7 @@ class Bot # set the default value for registry lookups, if the key sought is not # found, the default will be returned. The default default (har) is nil. def set_default (default) - @default = store(default) + @default = default end # just like Hash#each @@ -284,7 +274,7 @@ class Bot # delete a key from the registry def delete(key) - return nil unless File.exist?(@filename) + return @default unless File.exist?(@filename) return registry.delete(key) end |