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
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
Constructor Details
#initialize(status, headers, body) ⇒ Response
Returns a new instance of Response.
112 113 114 115 116 |
# File 'lib/mauth/rack.rb', line 112 def initialize(status, headers, body) @status = status @headers = headers @body = body end |
Instance Method Details
#attributes_for_signing ⇒ Object
122 123 124 125 126 127 128 |
# File 'lib/mauth/rack.rb', line 122 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
132 133 134 |
# File 'lib/mauth/rack.rb', line 132 def merge_headers(headers) self.class.new(@status, @headers.merge(headers), @body) end |
#status_headers_body ⇒ Object
118 119 120 |
# File 'lib/mauth/rack.rb', line 118 def status_headers_body [@status, @headers, @body] end |