diff options
author | Matthias H <apoc@sixserv.org> | 2014-03-06 12:46:47 +0100 |
---|---|---|
committer | Matthias H <apoc@sixserv.org> | 2014-03-06 12:46:47 +0100 |
commit | baf92378d7511983ae24cc41c7e9a86e73923bf4 (patch) | |
tree | 650d436a747ba7ede23c62fd149580476599399c /lib/rbot/registry.rb | |
parent | d642da9348926e418655685b92f0b68c11b710f1 (diff) |
[registry] added sqlite3 database adapter
Diffstat (limited to 'lib/rbot/registry.rb')
-rw-r--r-- | lib/rbot/registry.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/rbot/registry.rb b/lib/rbot/registry.rb index 0eefc9da..4fd5f77c 100644 --- a/lib/rbot/registry.rb +++ b/lib/rbot/registry.rb @@ -220,7 +220,7 @@ class Registry # like Hash#each def each(&block) return nil unless dbexists? - registry.each do |key| + registry.each_key do |key| block.call(key, self[key]) end end @@ -268,7 +268,10 @@ class Registry # delete a key from the registry def delete(key) return default unless dbexists? - return registry.delete(key.to_s) + value = registry.delete(key.to_s) + if value + restore(value) + end end # returns a list of your keys @@ -277,12 +280,6 @@ class Registry return registry.keys end - # just like Hash#has_both? - def has_both?(key, value) - return false unless dbexists? - registry.has_key?(key.to_s) and registry.has_value?(store(value)) - end - # Return an array of all associations [key, value] in your namespace def to_a return [] unless dbexists? |