class RailwayIpc::Responder

Attributes

block[R]

Public Class Methods

respond(&block) click to toggle source
# File lib/railway_ipc/responder.rb, line 5
def self.respond(&block)
  @block = block
end

Public Instance Methods

respond(request) click to toggle source
# File lib/railway_ipc/responder.rb, line 13
def respond(request)
  RailwayIpc.logger.info(
    'Responding to request',
    protobuf: { type: request.class, data: request },
    feature: 'railway_ipc_request'
  )
  response = self.class.block.call(request)
  raise ResponseTypeError.new(response.class) unless response.is_a?(Google::Protobuf::MessageExts)

  response
end