Class: Yarr::EvaluatorService

Inherits:
Object
  • Object
show all
Defined in:
lib/yarr/evaluator_service.rb

Overview

A wrapper on a web request that uses carc.in

Defined Under Namespace

Classes: Request, Response

Constant Summary collapse

URL =
'https://carc.in/run_requests'.freeze
CURRENT_RUBY =
'2.6.0'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(web_service = Typhoeus) ⇒ EvaluatorService

Returns a new instance of EvaluatorService.

Parameters:

  • web_service (Object) (defaults to: Typhoeus)

    web service adaptor


14
15
16
# File 'lib/yarr/evaluator_service.rb', line 14

def initialize(web_service = Typhoeus)
  @web_service = web_service
end

Instance Method Details

#request(request) ⇒ Response

Sends a request to the web service and returns the response

Parameters:

  • request (Request)

    the code to evaluate

Returns:

  • (Response)

    web service response object


21
22
23
24
25
26
27
28
29
# File 'lib/yarr/evaluator_service.rb', line 21

def request(request)
  response_body = @web_service.post(
    URL,
    body: request.to_wire,
    headers: headers
  ).response_body

  Response.new(response_body)
end