Class: ActiveResource::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/active_resource/http_mock.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, path, body = nil, headers = {}, options = {}) ⇒ Request

Returns a new instance of Request.



282
283
284
# 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

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



280
281
282
# File 'lib/active_resource/http_mock.rb', line 280

def body
  @body
end

#headersObject

Returns the value of attribute headers.



280
281
282
# File 'lib/active_resource/http_mock.rb', line 280

def headers
  @headers
end

#methodObject

Returns the value of attribute method.



280
281
282
# File 'lib/active_resource/http_mock.rb', line 280

def method
  @method
end

#pathObject

Returns the value of attribute path.



280
281
282
# File 'lib/active_resource/http_mock.rb', line 280

def path
  @path
end

Instance Method Details

#==(req) ⇒ Object



286
287
288
# 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_pathString

Removes query parameters from the path.

Returns:

  • (String)

    the path without query parameters



297
298
299
# File 'lib/active_resource/http_mock.rb', line 297

def remove_query_params_from_path
  path.split("?").first
end

#to_sObject



290
291
292
# File 'lib/active_resource/http_mock.rb', line 290

def to_s
  "<#{method.to_s.upcase}: #{path} [#{headers}] (#{body})>"
end