Class: HttpStub::Client::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/client/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Request

Returns a new instance of Request.


6
7
8
9
10
11
12
13
14
# File 'lib/http_stub/client/request.rb', line 6

def initialize(args)
  @base_uri     = URI(args[:base_uri])
  @path         = args[:path]
  @method       = args[:method]
  @headers      = args[:headers] || {}
  @parameters   = args[:parameters]
  @http_options = args[:http_options] || {}
  @intent       = args[:intent]
end

Instance Method Details

#error_message_prefixObject


22
23
24
# File 'lib/http_stub/client/request.rb', line 22

def error_message_prefix
  "Error occurred issuing request to #{@base_uri} - intent: #{@intent}, cause: "
end

#submitObject


16
17
18
19
20
# File 'lib/http_stub/client/request.rb', line 16

def submit
  Net::HTTP.start(@base_uri.host, @base_uri.port, @http_options) { |http| http.request(http_request) }
rescue StandardError => error
  raise "#{error_message_prefix} #{error}"
end