class Aws::Plugins::StubResponses::Handler

Public Instance Methods

apply_stub(stub, response) click to toggle source
# File lib/aws-sdk-core/plugins/stub_responses.rb, line 47
def apply_stub(stub, response)
  http_resp = response.context.http_response
  case
  when stub[:error] then signal_error(stub[:error], http_resp)
  when stub[:http] then signal_http(stub[:http], http_resp)
  when stub[:data] then response.data = stub[:data]
  end
end
call(context) click to toggle source
# File lib/aws-sdk-core/plugins/stub_responses.rb, line 40
def call(context)
  stub = context.client.next_stub(context.operation_name)
  resp = Seahorse::Client::Response.new(context: context)
  apply_stub(stub, resp)
  resp
end
signal_error(error, http_resp) click to toggle source

@param [Exception] stub @param [Seahorse::Client::Http::Response] http_resp

# File lib/aws-sdk-core/plugins/stub_responses.rb, line 58
def signal_error(error, http_resp)
  if Exception === error
    http_resp.signal_error(error)
  else
    http_resp.signal_error(error.new)
  end
end
signal_http(stub, http_resp) click to toggle source

@param [Seahorse::Client::Http::Response] stub @param [Seahorse::Client::Http::Response] http_resp

# File lib/aws-sdk-core/plugins/stub_responses.rb, line 68
def signal_http(stub, http_resp)
  http_resp.signal_headers(stub.status_code, stub.headers.to_h)
  while chunk = stub.body.read(1024 * 1024)
    http_resp.signal_data(chunk)
  end
  stub.body.rewind
  http_resp.signal_done
end