Class: Droonga::Replier

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/droonga/replier.rb

Instance Method Summary collapse

Constructor Details

#initialize(forwarder) ⇒ Replier

Returns a new instance of Replier.



23
24
25
# File 'lib/droonga/replier.rb', line 23

def initialize(forwarder)
  @forwarder = forwarder
end

Instance Method Details

#reply(message) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/droonga/replier.rb', line 27

def reply(message)
  logger.trace("reply: start")
  destination = message["replyTo"]
  reply_message = {
    "inReplyTo"  => message["id"],
    "statusCode" => message["statusCode"] || StatusCode::OK,
    "type"       => destination["type"],
    "body"       => message["body"],
  }
  if message.include?("errors")
    errors = message["errors"]
    reply_message["errors"] = errors unless errors.empty?
  end
  @forwarder.forward(reply_message, destination)
  logger.trace("reply: done")
end