Parent

Files

ActiveResource::Response

Attributes

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

Public Class Methods

new(body, message = 200, headers = {}) click to toggle source
     # File lib/active_resource/http_mock.rb, line 286
286:     def initialize(body, message = 200, headers = {})
287:       @body, @message, @headers = body, message.to_s, headers
288:       @code = @message[0,3].to_i
289: 
290:       resp_cls = Net::HTTPResponse::CODE_TO_OBJ[@code.to_s]
291:       if resp_cls && !resp_cls.body_permitted?
292:         @body = nil
293:       end
294: 
295:       if @body.nil?
296:         self['Content-Length'] = "0"
297:       else
298:         self['Content-Length'] = body.size.to_s
299:       end
300:     end

Public Instance Methods

==(other) click to toggle source

Returns true if the other is a Response with an equal body, equal message and equal headers. Otherwise it returns false.

     # File lib/active_resource/http_mock.rb, line 318
318:     def ==(other)
319:       if (other.is_a?(Response))
320:         other.body == body && other.message == message && other.headers == headers
321:       else
322:         false
323:       end
324:     end
[](key) click to toggle source
     # File lib/active_resource/http_mock.rb, line 308
308:     def [](key)
309:       headers[key]
310:     end
[]=(key, value) click to toggle source
     # File lib/active_resource/http_mock.rb, line 312
312:     def []=(key, value)
313:       headers[key] = value
314:     end
success?() click to toggle source

Returns true if code is 2xx, false otherwise.

     # File lib/active_resource/http_mock.rb, line 304
304:     def success?
305:       code.in?(200..299)
306:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.