class Github::ResponseWrapper
A class responsible for proxing to faraday response
def ==(other)
Compare the wrapper with other wrapper for equality
def ==(other) return false unless other.is_a?(self.class) return false unless (other.respond_to?(:env) && other.respond_to?(:body)) self.env == other.env && self.body == other.body end
def [](key)
Convert any key to string before calling.
Lookup an attribute from the body if hash, otherwise behave like array index.
def [](key) if self.body.is_a?(Array) self.body[key] else self.body.send(:"#{key}") end end
def body
Response raw body
def body @body ? @body : response.body end
def body=(value)
def body=(value) @body = value @env[:body] = value end
def client_error?
def client_error? status.to_i >= 400 && status.to_i < 500 end
def each
Iterate over each resource inside the body
def each body_parts = self.body.respond_to?(:each) ? self.body : [self.body] return body_parts.to_enum unless block_given? body_parts.each { |part| yield(part) } end
def has_key?(key)
Check if body has an attribute
def has_key?(key) self.body.is_a?(Hash) && self.body.has_key?(key) end
def headers
Return response headers
def headers Github::Response::Header.new(env) end
def initialize(response, current_api)
def initialize(response, current_api) @response = response @current_api = current_api @env = response.env end
def inspect
Print only response body
def inspect "#<#{self.class.name} @body=\"#{self.body}\">" end
def method_missing(method_name, *args, &block)
Coerce any method calls for body attributes
def method_missing(method_name, *args, &block) if self.has_key?(method_name.to_s) self.[](method_name, &block) else super end end
def redirect?
def redirect? status.to_i >= 300 && status.to_i < 400 end
def respond_to?(method_name, include_all = false)
Check if method is defined on the body
def respond_to?(method_name, include_all = false) if self.has_key?(method_name.to_s) true else super end end
def server_error?
def server_error? status.to_i >= 500 && status.to_i < 600 end
def status
Response status
def status response.status end
def success?
def success? response.success? end
def to_ary
Convert the ResponseWrapper into an Array
def to_ary body.to_ary end
def to_hash
Convert the ResponseWrapper into a Hash
def to_hash body.to_hash end
def to_s
Return response body as string
def to_s body.to_s end
def url
Request url
def url response.env[:url].to_s end