Class: HttpStub::Configurer::Server::CommandProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/configurer/server/command_processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(configurer) ⇒ CommandProcessor

Returns a new instance of CommandProcessor.



7
8
9
# File 'lib/http_stub/configurer/server/command_processor.rb', line 7

def initialize(configurer)
  @configurer = configurer
end

Instance Method Details

#process(command) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/http_stub/configurer/server/command_processor.rb', line 11

def process(command)
  response = Net::HTTP.start(host, port) { |http| http.request(command.http_request) }
  raise "#{error_message_prefix(command)}: #{response.code} #{response.message}" unless response.code == "200"
  response
rescue StandardError => err
  raise "#{error_message_prefix(command)}: #{err}"
end