class ActiveResource::Request

Attributes

body[RW]
headers[RW]
method[RW]
path[RW]

Public Class Methods

new(method, path, body = nil, headers = {}, options = {}) click to toggle source
# File lib/active_resource/http_mock.rb, line 282
def initialize(method, path, body = nil, headers = {}, options = {})
  @method, @path, @body, @headers, @options = method, path, body, headers, options
end

Public Instance Methods

==(req) click to toggle source
# File lib/active_resource/http_mock.rb, line 286
def ==(req)
  same_path?(req) && method == req.method && headers_match?(req)
end
remove_query_params_from_path() click to toggle source

Removes query parameters from the path.

@return [String] the path without query parameters

# File lib/active_resource/http_mock.rb, line 297
def remove_query_params_from_path
  path.split("?").first
end
to_s() click to toggle source
# File lib/active_resource/http_mock.rb, line 290
def to_s
  "<#{method.to_s.upcase}: #{path} [#{headers}] (#{body})>"
end

Private Instance Methods

headers_match?(req) click to toggle source
# File lib/active_resource/http_mock.rb, line 310
def headers_match?(req)
  # Ignore format header on equality if it's not defined
  format_header = ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[method]
  if headers[format_header].present? || req.headers[format_header].blank?
    headers == req.headers
  else
    headers.dup.merge(format_header => req.headers[format_header]) == req.headers
  end
end
same_path?(req) click to toggle source
# File lib/active_resource/http_mock.rb, line 302
def same_path?(req)
  if @options && @options[:omit_query_in_path]
    remove_query_params_from_path == req.remove_query_params_from_path
  else
    path == req.path
  end
end