class WebMock::RequestSignature
Attributes
body[RW]
headers[R]
method[RW]
uri[RW]
Public Class Methods
new(method, uri, options = {})
click to toggle source
# File lib/webmock/request_signature.rb, line 10 def initialize(method, uri, options = {}) self.method = method.to_sym self.uri = uri.is_a?(Addressable::URI) ? uri : WebMock::Util::URI.normalize_uri(uri) assign_options(options) end
Public Instance Methods
eql?(other)
click to toggle source
# File lib/webmock/request_signature.rb, line 34 def eql?(other) self.to_s == other.to_s end
Also aliased as: ==
hash()
click to toggle source
# File lib/webmock/request_signature.rb, line 30 def hash self.to_s.hash end
headers=(headers)
click to toggle source
# File lib/webmock/request_signature.rb, line 26 def headers=(headers) @headers = WebMock::Util::Headers.normalize_headers(headers) end
json_headers?()
click to toggle source
# File lib/webmock/request_signature.rb, line 43 def json_headers? !!(headers&.fetch('Content-Type', nil)&.start_with?('application/json')) end
to_s()
click to toggle source
# 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?()
click to toggle source
# File lib/webmock/request_signature.rb, line 39 def url_encoded? !!(headers&.fetch('Content-Type', nil)&.start_with?('application/x-www-form-urlencoded')) end
Private Instance Methods
assign_options(options)
click to toggle source
# File lib/webmock/request_signature.rb, line 49 def assign_options(options) self.body = options[:body] if options.has_key?(:body) self.headers = options[:headers] if options.has_key?(:headers) end