Class: MAuth::Rack::Response
- Inherits:
-
MAuth::Response
- Object
- MAuth::Response
- MAuth::Rack::Response
- Defined in:
- lib/mauth/rack.rb
Overview
representation of a response composed from a rack response (status, headers, body) which can be passed to a Mauth::Client for signing
Constant Summary
Constants inherited from MAuth::Response
MAuth::Response::SIGNATURE_COMPONENTS, MAuth::Response::SIGNATURE_COMPONENTS_V2
Instance Method Summary collapse
- #attributes_for_signing ⇒ Object
-
#initialize(status, headers, body) ⇒ Response
constructor
A new instance of Response.
-
#merge_headers(headers) ⇒ Object
takes a Hash of headers; returns an instance of this class whose headers have been updated with the argument headers.
- #status_headers_body ⇒ Object
Methods included from Signable
#encode_query_string, #string_to_sign_v1, #string_to_sign_v2, #uri_escape
Constructor Details
#initialize(status, headers, body) ⇒ Response
Returns a new instance of Response.
156 157 158 159 160 |
# File 'lib/mauth/rack.rb', line 156 def initialize(status, headers, body) @status = status @headers = headers @body = body end |
Instance Method Details
#attributes_for_signing ⇒ Object
166 167 168 169 170 171 172 |
# File 'lib/mauth/rack.rb', line 166 def attributes_for_signing @attributes_for_signing ||= begin body = '' @body.each { |part| body << part } # note: rack only requires #each be defined on the body, so not using map or inject { status_code: @status.to_i, body: body } end end |
#merge_headers(headers) ⇒ Object
takes a Hash of headers; returns an instance of this class whose headers have been updated with the argument headers
176 177 178 |
# File 'lib/mauth/rack.rb', line 176 def merge_headers(headers) self.class.new(@status, @headers.merge(headers), @body) end |
#status_headers_body ⇒ Object
162 163 164 |
# File 'lib/mauth/rack.rb', line 162 def status_headers_body [@status, @headers, @body] end |