Skip to content

Commit

Permalink
Receive all responses from the Droonga Engine.
Browse files Browse the repository at this point in the history
If there is only one response, receive() returns the first response. Otherwise it returns an array of all responses. Because the receiver receives only "Droonga message format" objects, we don't have to think about array responses.
  • Loading branch information
piroor committed Jan 24, 2014
1 parent ef36845 commit 48f203a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/droonga/client/connection/droonga_protocol.rb
Expand Up @@ -184,12 +184,16 @@ def receive(receiver, options)
responses = []
receiver.receive(receive_options) do |response|
responses << response
if block_given?
yield(response)
end
end
response = responses.first
if block_given?
yield(response)
else
response
unless block_given?
if responses.size > 1
responses
else
response
end
end
ensure
receiver.close
Expand Down

0 comments on commit 48f203a

Please sign in to comment.