]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
TokyoCabinet #fwmkeys() expects a string
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 6 Oct 2010 18:52:29 +0000 (20:52 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 6 Oct 2010 18:52:29 +0000 (20:52 +0200)
Convert the (optional) first argument to #each*() methods to a string to
ensure the calls work as expected. This fixes a problem with
@registry.each not working as expected, and although it would have been
sufficient to convert the default for the first argument from nil to the
empty string, the approach implemented by this patch is more robust
overall.

lib/rbot/registry/tc.rb

index b735927c87c60c23f0c92825ad2cfe5fb7a56148..c114a1be696ac94fe8b8b8f393b9e9e10e55a8cd 100644 (file)
@@ -405,7 +405,7 @@ class Bot
     # just like Hash#each
     def each(set=nil, bulk=0, &block)
       return nil unless File.exist?(@filename)
-      registry.fwmkeys(set).each {|key|
+      registry.fwmkeys(set.to_s).each {|key|
         block.call(key, restore(registry[key]))
       }
     end
@@ -413,7 +413,7 @@ class Bot
     # just like Hash#each_key
     def each_key(set=nil, bulk=0, &block)
       return nil unless File.exist?(@filename)
-      registry.fwmkeys(set).each do |key|
+      registry.fwmkeys(set.to_s).each do |key|
         block.call(key)
       end
     end
@@ -421,7 +421,7 @@ class Bot
     # just like Hash#each_value
     def each_value(set=nil, bulk=0, &block)
       return nil unless File.exist?(@filename)
-      registry.fwmkeys(set).each do |key|
+      registry.fwmkeys(set.to_s).each do |key|
         block.call(restore(registry[key]))
       end
     end