Class: WebMock::RequestSignature
- Inherits:
-
Object
- Object
- WebMock::RequestSignature
- Defined in:
- lib/webmock/request_signature.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#method ⇒ Object
Returns the value of attribute method.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(method, uri, options = {}) ⇒ RequestSignature
constructor
A new instance of RequestSignature.
- #json_headers? ⇒ Boolean
- #to_s ⇒ Object
- #url_encoded? ⇒ Boolean
Constructor Details
#initialize(method, uri, options = {}) ⇒ RequestSignature
Returns a new instance of RequestSignature.
10 11 12 13 14 |
# File 'lib/webmock/request_signature.rb', line 10 def initialize(method, uri, = {}) self.method = method.to_sym self.uri = uri.is_a?(Addressable::URI) ? uri : WebMock::Util::URI.normalize_uri(uri) () end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
7 8 9 |
# File 'lib/webmock/request_signature.rb', line 7 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
8 9 10 |
# File 'lib/webmock/request_signature.rb', line 8 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
7 8 9 |
# File 'lib/webmock/request_signature.rb', line 7 def method @method end |
#uri ⇒ Object
Returns the value of attribute uri.
7 8 9 |
# File 'lib/webmock/request_signature.rb', line 7 def uri @uri end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
34 35 36 |
# File 'lib/webmock/request_signature.rb', line 34 def eql?(other) self.to_s == other.to_s end |
#hash ⇒ Object
30 31 32 |
# File 'lib/webmock/request_signature.rb', line 30 def hash self.to_s.hash end |
#json_headers? ⇒ Boolean
43 44 45 |
# File 'lib/webmock/request_signature.rb', line 43 def json_headers? !!(headers&.fetch('Content-Type', nil)&.start_with?('application/json')) end |
#to_s ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/webmock/request_signature.rb', line 16 def to_s string = "#{self.method.to_s.upcase}".dup string << " #{WebMock::Util::URI.strip_default_port_from_uri_string(self.uri.to_s)}" string << " with body '#{body.to_s}'" if body && body.to_s != '' if headers && !headers.empty? string << " with headers #{WebMock::Util::Headers.sorted_headers_string(headers)}" end string end |
#url_encoded? ⇒ Boolean
39 40 41 |
# File 'lib/webmock/request_signature.rb', line 39 def url_encoded? !!(headers&.fetch('Content-Type', nil)&.start_with?('application/x-www-form-urlencoded')) end |