class Patchboard::Response

Attributes

data[R]
parsed_headers[R]
raw[R]
resource[RW]

Public Class Methods

new(raw) click to toggle source
# File lib/patchboard/response.rb, line 47
def initialize(raw)
  @raw = raw
  if @raw.headers["Content-Type"]
    if @raw.headers["Content-Type"] =~ %r{application/.*json}
      @data = JSON.parse @raw.body, :symbolize_names => true
    end
  end
  @parsed_headers = {}
  parse_headers
end

Public Instance Methods

method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File lib/patchboard/response.rb, line 67
def method_missing(name, *args, &block)
  if @raw.respond_to? name
    @raw.send(name, *args, &block)
  else
    super
  end
end
parse_headers() click to toggle source
# File lib/patchboard/response.rb, line 58
def parse_headers
  @raw.headers.each do |name, string|
    case name
    when /www-authenticate/i
      @parsed_headers["WWW-Authenticate"] = Headers.parse_www_auth(string)
    end
  end
end
respond_to?(*args) click to toggle source
Calls superclass method
# File lib/patchboard/response.rb, line 75
def respond_to?(*args)
  @raw.respond_to?(*args) || super
end