Class: Groonga::Client::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga/client/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Command

Returns a new instance of Command.



26
27
28
# File 'lib/groonga/client/command.rb', line 26

def initialize(command)
  @command = command
end

Instance Method Details

#execute(connection) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/groonga/client/command.rb', line 30

def execute(connection)
  async = block_given?

  response = nil
  request = connection.send(@command) do |raw_response|
    response = parse_raw_response(raw_response)
    yield(response) if async
  end

  if async
    request
  else
    request.wait
    response
  end
end