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.
8 9 10 11 12 |
# File 'lib/webmock/request_signature.rb', line 8 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.
5 6 7 |
# File 'lib/webmock/request_signature.rb', line 5 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
6 7 8 |
# File 'lib/webmock/request_signature.rb', line 6 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
5 6 7 |
# File 'lib/webmock/request_signature.rb', line 5 def method @method end |
#uri ⇒ Object
Returns the value of attribute uri.
5 6 7 |
# File 'lib/webmock/request_signature.rb', line 5 def uri @uri end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
32 33 34 |
# File 'lib/webmock/request_signature.rb', line 32 def eql?(other) self.to_s == other.to_s end |
#hash ⇒ Object
28 29 30 |
# File 'lib/webmock/request_signature.rb', line 28 def hash self.to_s.hash end |
#json_headers? ⇒ Boolean
41 42 43 |
# File 'lib/webmock/request_signature.rb', line 41 def json_headers? !!(headers&.fetch('Content-Type', nil)&.start_with?('application/json')) end |
#to_s ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/webmock/request_signature.rb', line 14 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
37 38 39 |
# File 'lib/webmock/request_signature.rb', line 37 def url_encoded? !!(headers&.fetch('Content-Type', nil)&.start_with?('application/x-www-form-urlencoded')) end |