Class: ActiveResource::Response

### Home Classes Methods

### In Files

- lib/active_resource/http_mock.rb

### Parent

Object

### Methods

- ::new
- #==
- #[]
- #[]=
- #success?

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- ActiveResource
- ActiveResource::BadRequest
- ActiveResource::Base
- ActiveResource::ClientError
- ActiveResource::Connection
- ActiveResource::CustomMethods
- ActiveResource::CustomMethods::ClassMethods
- ActiveResource::CustomMethods::InstanceMethods
- ActiveResource::Errors
- ActiveResource::ForbiddenAccess
- ActiveResource::Formats
- ActiveResource::Formats::JsonFormat
- ActiveResource::Formats::XmlFormat
- ActiveResource::HttpMock
- ActiveResource::InvalidRequestError
- ActiveResource::LogSubscriber
- ActiveResource::Observing
- ActiveResource::Railtie
- ActiveResource::Request
- ActiveResource::ResourceConflict
- ActiveResource::ResourceGone
- ActiveResource::ResourceNotFound
- ActiveResource::Response
- ActiveResource::SSLError
- ActiveResource::ServerError
- ActiveResource::TimeoutError
- ActiveResource::UnauthorizedAccess
- ActiveResource::Validations

No matching classes.

# ActiveResource::Response

### Attributes

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

### Public Class Methods

new(body, message = 200, headers = {}) click to toggle source

    # File lib/active_resource/http_mock.rb, line 256
    def initialize(body, message = 200, headers = {})
      @body, @message, @headers = body, message.to_s, headers
      @code = @message[0,3].to_i

      resp_cls = Net::HTTPResponse::CODE_TO_OBJ[@code.to_s]
      if resp_cls && !resp_cls.body_permitted?
        @body = nil
      end

      if @body.nil?
        self['Content-Length'] = "0"
      else
        self['Content-Length'] = body.size.to_s
      end
    end

### Public Instance Methods

==(other) click to toggle source

    # File lib/active_resource/http_mock.rb, line 284
    def ==(other)
      if (other.is_a?(Response))
        other.body == body && other.message == message && other.headers == headers
      else
        false
      end
    end

[](key) click to toggle source

    # File lib/active_resource/http_mock.rb, line 276
    def [](key)
      headers[key]
    end

[]=(key, value) click to toggle source

    # File lib/active_resource/http_mock.rb, line 280
    def []=(key, value)
      headers[key] = value
    end

success?() click to toggle source

    # File lib/active_resource/http_mock.rb, line 272
    def success?
      (200..299).include?(code)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.