Class: Aws::Plugins::StubResponses::Handler
Instance Attribute Summary
#handler
Instance Method Summary
collapse
#initialize, #inspect
Instance Method Details
#apply_stub(stub, response) ⇒ Object
47
48
49
50
51
52
53
54
|
# 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) ⇒ Object
40
41
42
43
44
45
|
# 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) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/aws-sdk-core/plugins/stub_responses.rb', line 56
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) ⇒ Object
66
67
68
69
70
71
72
73
|
# File 'lib/aws-sdk-core/plugins/stub_responses.rb', line 66
def signal_http(stub, http_resp)
http_resp.(stub.status_code, stub..to_h)
while chunk = stub.body.read(1024 * 1024)
http_resp.signal_data(chunk)
end
stub.body.rewind
http_resp.signal_done
end
|