[Groonga-commit] droonga/droonga-client-ruby at 29bf0bc [master] Simplify receive

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Fri Jan 24 15:58:18 JST 2014


Kouhei Sutou	2014-01-24 15:58:18 +0900 (Fri, 24 Jan 2014)

  New Revision: 29bf0bca7ee7614ecef80bf732ff5b6ac254299d
  https://github.com/droonga/droonga-client-ruby/commit/29bf0bca7ee7614ecef80bf732ff5b6ac254299d

  Message:
    Simplify receive

  Modified files:
    lib/droonga/client/connection/droonga_protocol.rb

  Modified: lib/droonga/client/connection/droonga_protocol.rb (+10 -13)
===================================================================
--- lib/droonga/client/connection/droonga_protocol.rb    2014-01-24 15:16:31 +0900 (a9eb9e9)
+++ lib/droonga/client/connection/droonga_protocol.rb    2014-01-24 15:58:18 +0900 (f24dc8d)
@@ -79,7 +79,15 @@ module Droonga
 
           sync = block.nil?
           if sync
-            receive(receiver, options, &block)
+            responses = []
+            receive(receiver, options) do |response|
+              responses << response
+            end
+            if responses.size > 1
+              responses
+            else
+              responses.first
+            end
           else
             thread = Thread.new do
               receive(receiver, options, &block)
@@ -181,19 +189,8 @@ module Droonga
             :timeout => timeout,
           }
           begin
-            responses = []
             receiver.receive(receive_options) do |response|
-              responses << response
-              if block_given?
-                yield(response)
-              end
-            end
-            unless block_given?
-              if responses.size > 1
-                responses
-              else
-                responses.first
-              end
+              yield(response)
             end
           ensure
             receiver.close
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る