Class: MAuth::Faraday::Request
Overview
representation of a request (outgoing) composed from a Faraday request env which can be passed to a Mauth::Client for signing
Constant Summary
Constants inherited from Request
Instance Attribute Summary collapse
-
#request_env ⇒ Object
readonly
Returns the value of attribute request_env.
Instance Method Summary collapse
- #attributes_for_signing ⇒ Object
-
#initialize(request_env) ⇒ Request
constructor
A new instance of Request.
-
#merge_headers(headers) ⇒ Object
takes a Hash of headers; returns an instance of this class whose headers have been merged with the argument headers.
Methods included from Signable
Constructor Details
#initialize(request_env) ⇒ Request
Returns a new instance of Request.
34 35 36 |
# File 'lib/mauth/faraday.rb', line 34 def initialize(request_env) @request_env = request_env end |
Instance Attribute Details
#request_env ⇒ Object (readonly)
Returns the value of attribute request_env.
33 34 35 |
# File 'lib/mauth/faraday.rb', line 33 def request_env @request_env end |
Instance Method Details
#attributes_for_signing ⇒ Object
38 39 40 41 42 |
# File 'lib/mauth/faraday.rb', line 38 def attributes_for_signing request_url = @request_env[:url].path request_url = '/' if request_url.empty? @attributes_for_signing ||= { verb: @request_env[:method].to_s.upcase, request_url: request_url, body: @request_env[:body] } end |
#merge_headers(headers) ⇒ Object
takes a Hash of headers; returns an instance of this class whose headers have been merged with the argument headers
46 47 48 |
# File 'lib/mauth/faraday.rb', line 46 def merge_headers(headers) self.class.new(@request_env.merge(request_headers: @request_env[:request_headers].merge(headers))) end |