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 = {}) ⇒ Request

Returns a new instance of Request.



77
78
79
# File 'lib/active_resource/http_mock.rb', line 77

def initialize(method, path, body = nil, headers = {})
  @method, @path, @body, @headers = method, path, body, headers.reverse_merge('Content-Type' => 'application/xml')
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



75
76
77
# File 'lib/active_resource/http_mock.rb', line 75

def body
  @body
end

#headersObject

Returns the value of attribute headers.



75
76
77
# File 'lib/active_resource/http_mock.rb', line 75

def headers
  @headers
end

#methodObject

Returns the value of attribute method.



75
76
77
# File 'lib/active_resource/http_mock.rb', line 75

def method
  @method
end

#pathObject

Returns the value of attribute path.



75
76
77
# File 'lib/active_resource/http_mock.rb', line 75

def path
  @path
end

Instance Method Details

#==(other_request) ⇒ Object



81
82
83
# File 'lib/active_resource/http_mock.rb', line 81

def ==(other_request)
  other_request.hash == hash
end

#eql?(other_request) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/active_resource/http_mock.rb', line 85

def eql?(other_request)
  self == other_request
end

#hashObject



93
94
95
# File 'lib/active_resource/http_mock.rb', line 93

def hash
  "#{path}#{method}#{headers}".hash
end

#to_sObject



89
90
91
# File 'lib/active_resource/http_mock.rb', line 89

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