class Aws::Plugins::StubResponses::Handler
Public Instance Methods
call(context)
click to toggle source
# File lib/aws-sdk-core/plugins/stub_responses.rb, line 40 def call(context) response = Seahorse::Client::Response.new(context: context) apply_stub(response, context.client.next_stub(context.operation_name)) response end
Private Instance Methods
apply_stub(resp, stub)
click to toggle source
# File lib/aws-sdk-core/plugins/stub_responses.rb, line 48 def apply_stub(resp, stub) if Exception === stub resp.error = stub elsif Class === stub && stub.ancestors.include?(Errors::ServiceError) resp.error = stub.new(resp.context, 'stubbed error') elsif Class === stub && stub.ancestors.include?(Exception) resp.error = stub.new else resp.data = stub stub_http_body(resp) if streaming?(resp) end end
streaming?(resp)
click to toggle source
# File lib/aws-sdk-core/plugins/stub_responses.rb, line 61 def streaming?(resp) if output = resp.context.operation.output payload = output.payload_member payload && payload.definition['streaming'] == true else false end end
stub_http_body(resp)
click to toggle source
# File lib/aws-sdk-core/plugins/stub_responses.rb, line 70 def stub_http_body(resp) payload = resp.context.operation.output.payload body = resp.context.http_response.body body.write(resp.data[payload]) body.rewind if body.respond_to?(:rewind) resp.data[payload] = body end