Class: Seahorse::Client::Response
- Inherits:
-
Delegator
- Object
- Delegator
- Seahorse::Client::Response
- Defined in:
- gems/aws-sdk-core/lib/seahorse/client/response.rb
Instance Attribute Summary collapse
-
#context ⇒ RequestContext
readonly
-
#data ⇒ Object
The response data.
-
#error ⇒ StandardError?
Instance Method Summary collapse
-
#checksum_validated ⇒ String?
Returns the algorithm used to validate the response checksum.
-
#initialize(options = {}) ⇒ Response
constructor
A new instance of Response.
-
#on(range, &_block) ⇒ self
-
#on_success(&block) ⇒ self
Yields to the block if the response has a 200 level status code.
-
#successful? ⇒ Boolean
Returns
true
if the response is complete with a ~ 200 level http status code.
Constructor Details
#initialize(options = {}) ⇒ Response
Returns a new instance of Response.
12 13 14 15 16 17 18 19 20 21 |
# File 'gems/aws-sdk-core/lib/seahorse/client/response.rb', line 12 def initialize( = {}) @context = [:context] || RequestContext.new @data = [:data] @error = [:error] @http_request = @context.http_request @http_response = @context.http_response @http_response.on_error do |error| @error = error end end |
Instance Attribute Details
#context ⇒ RequestContext (readonly)
24 25 26 |
# File 'gems/aws-sdk-core/lib/seahorse/client/response.rb', line 24 def context @context end |
#data ⇒ Object
Returns The response data. This may be nil
if the response contains
an #error.
28 29 30 |
# File 'gems/aws-sdk-core/lib/seahorse/client/response.rb', line 28 def data @data end |
#error ⇒ StandardError?
31 32 33 |
# File 'gems/aws-sdk-core/lib/seahorse/client/response.rb', line 31 def error @error end |
Instance Method Details
#checksum_validated ⇒ String?
Returns the algorithm used to validate the response checksum. Returns nil if no verification was done.
35 36 37 |
# File 'gems/aws-sdk-core/lib/seahorse/client/response.rb', line 35 def checksum_validated context[:http_checksum][:validated] if context[:http_checksum] end |
#on(status_code, &block) ⇒ self #on(status_code_range, &block) ⇒ self
49 50 51 52 53 54 55 |
# File 'gems/aws-sdk-core/lib/seahorse/client/response.rb', line 49 def on(range, &_block) response = self @context.http_response.on_success(range) do yield response end self end |
#on_success(&block) ⇒ self
Yields to the block if the response has a 200 level status code.
59 60 61 |
# File 'gems/aws-sdk-core/lib/seahorse/client/response.rb', line 59 def on_success(&block) on(200..299, &block) end |
#successful? ⇒ Boolean
Returns true
if the response is complete with
a ~ 200 level http status code.
65 66 67 |
# File 'gems/aws-sdk-core/lib/seahorse/client/response.rb', line 65 def successful? (200..299).cover?(@context.http_response.status_code) && @error.nil? end |