Class ActiveResource::Response
In: vendor/rails/activeresource/lib/active_resource/http_mock.rb
Parent: Object

Methods

==   []   []=   new   success?  

Attributes

body  [RW] 
code  [RW] 
headers  [RW] 
message  [RW] 

Public Class methods

[Source]

     # File vendor/rails/activeresource/lib/active_resource/http_mock.rb, line 175
175:     def initialize(body, message = 200, headers = {})
176:       @body, @message, @headers = body, message.to_s, headers
177:       @code = @message[0,3].to_i
178: 
179:       resp_cls = Net::HTTPResponse::CODE_TO_OBJ[@code.to_s]
180:       if resp_cls && !resp_cls.body_permitted?
181:         @body = nil
182:       end
183: 
184:       if @body.nil?
185:         self['Content-Length'] = "0"
186:       else
187:         self['Content-Length'] = body.size.to_s
188:       end
189:     end

Public Instance methods

[Source]

     # File vendor/rails/activeresource/lib/active_resource/http_mock.rb, line 203
203:     def ==(other)
204:       if (other.is_a?(Response))
205:         other.body == body && other.message == message && other.headers == headers
206:       else
207:         false
208:       end
209:     end

[Source]

     # File vendor/rails/activeresource/lib/active_resource/http_mock.rb, line 195
195:     def [](key)
196:       headers[key]
197:     end

[Source]

     # File vendor/rails/activeresource/lib/active_resource/http_mock.rb, line 199
199:     def []=(key, value)
200:       headers[key] = value
201:     end

[Source]

     # File vendor/rails/activeresource/lib/active_resource/http_mock.rb, line 191
191:     def success?
192:       (200..299).include?(code)
193:     end

[Validate]