### Home Classes Methods

### In Files

- lib/github_api/response_wrapper.rb

### Parent

Object

### Methods

- ::new
- #==
- #[]
- #body
- #body=
- #client_error?
- #each
- #eql?
- #has_key?
- #headers
- #inspect
- #method_missing
- #redirect?
- #respond_to?
- #server_error?
- #status
- #success?
- #to_ary
- #to_hash
- #to_s
- #url

### Included Modules

- Github::Pagination
- Enumerable

### Class/Module Index

Quicksearch

- Github
- Github::API
- Github::Activity
- Github::Activity::Events
- Github::Activity::Notifications
- Github::Activity::Starring
- Github::Activity::Watching
- Github::ApiFactory
- Github::Arguments
- Github::Authorization
- Github::Authorizations
- Github::AutoloadHelper
- Github::Client
- Github::Configuration
- Github::Connection
- Github::Constants
- Github::CoreExt
- Github::CoreExt::OrderedHash
- Github::Descendants
- Github::Emojis
- Github::Error
- Github::Error::BadRequest
- Github::Error::ClientError
- Github::Error::Forbidden
- Github::Error::GithubError
- Github::Error::InternalServerError
- Github::Error::InvalidOptions
- Github::Error::NotAcceptable
- Github::Error::NotFound
- Github::Error::RequiredParams
- Github::Error::ServiceError
- Github::Error::ServiceUnavailable
- Github::Error::Unauthorized
- Github::Error::UnknownValue
- Github::Error::UnprocessableEntity
- Github::Error::Validations
- Github::Gists
- Github::Gists::Comments
- Github::GitData
- Github::GitData::Blobs
- Github::GitData::Commits
- Github::GitData::References
- Github::GitData::Tags
- Github::GitData::Trees
- Github::Gitignore
- Github::Issues
- Github::Issues::Assignees
- Github::Issues::Comments
- Github::Issues::Events
- Github::Issues::Labels
- Github::Issues::Milestones
- Github::Jsonable
- Github::Markdown
- Github::Meta
- Github::MimeType
- Github::Normalizer
- Github::Orgs
- Github::Orgs::Members
- Github::Orgs::Teams
- Github::PageIterator
- Github::PageLinks
- Github::PagedRequest
- Github::Pagination
- Github::ParameterFilter
- Github::ParamsHash
- Github::PullRequests
- Github::PullRequests::Comments
- Github::RateLimit
- Github::Repos
- Github::Repos::Collaborators
- Github::Repos::Comments
- Github::Repos::Commits
- Github::Repos::Contents
- Github::Repos::Downloads
- Github::Repos::Forks
- Github::Repos::Hooks
- Github::Repos::Keys
- Github::Repos::Merging
- Github::Repos::PubSubHubbub
- Github::Repos::Statistics
- Github::Repos::Statuses
- Github::Request
- Github::Request::BasicAuth
- Github::Request::Jsonize
- Github::Request::OAuth2
- Github::Resource
- Github::Response
- Github::Response::Header
- Github::Response::Jsonize
- Github::Response::Mashify
- Github::Response::RaiseError
- Github::Response::Xmlize
- Github::ResponseWrapper
- Github::S3Uploader
- Github::Say
- Github::Scopes
- Github::Search
- Github::Users
- Github::Users::Emails
- Github::Users::Followers
- Github::Users::Keys
- Github::Utils
- Github::Utils::Url
- Github::VERSION
- Github::Validations
- Github::Validations::Format
- Github::Validations::Presence
- Github::Validations::Required
- Github::Validations::Token
- Hash

No matching classes.

# Github::ResponseWrapper

A class responsible for proxing to faraday response

### Attributes

current_api[R]
env[R]
response[R]

### Public Class Methods

new(response, current_api) click to toggle source

    # File lib/github_api/response_wrapper.rb, line 18
    def initialize(response, current_api)
      @response    = response
      @current_api = current_api
      @env         = response.env
    end

### Public Instance Methods

==(other) click to toggle source

Compare the wrapper with other wrapper for equality

    # File lib/github_api/response_wrapper.rb, line 148
    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

Also aliased as: eql?
[](key) click to toggle source

Lookup an attribute from the body if hash, otherwise behave like array index. Convert any key to string before calling.

    # File lib/github_api/response_wrapper.rb, line 80
    def [](key)
      if self.body.is_a?(Array)
        self.body[key]
      else
        self.body.send(:"#{key}")
      end
    end

body() click to toggle source

Response raw body

    # File lib/github_api/response_wrapper.rb, line 45
    def body
      @body ? @body : response.body
    end

body=(value) click to toggle source

    # File lib/github_api/response_wrapper.rb, line 38
    def body=(value)
      @body = value
      @env[:body] = value
    end

client_error?() click to toggle source

    # File lib/github_api/response_wrapper.rb, line 63
    def client_error?
      status.to_i >= 400 && status.to_i < 500
    end

each() click to toggle source

Iterate over each resource inside the body

    # File lib/github_api/response_wrapper.rb, line 108
    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

eql?(other) click to toggle source
Alias for: ==
has_key?(key) click to toggle source

Check if body has an attribute

    # File lib/github_api/response_wrapper.rb, line 116
    def has_key?(key)
      self.body.is_a?(Hash) && self.body.has_key?(key)
    end

headers() click to toggle source

Return response headers

    # File lib/github_api/response_wrapper.rb, line 73
    def headers
      Github::Response::Header.new(env)
    end

inspect() click to toggle source

Print only response body

    # File lib/github_api/response_wrapper.rb, line 142
    def inspect
      "#<#{self.class.name} @body=\"#{self.body}\">"
    end

method_missing(method_name, *args, &block) click to toggle source

Coerce any method calls for body attributes

    # File lib/github_api/response_wrapper.rb, line 122
    def method_missing(method_name, *args, &block)
      if self.has_key?(method_name.to_s)
        self.[](method_name, &block)
      else
        super
      end
    end

redirect?() click to toggle source

    # File lib/github_api/response_wrapper.rb, line 59
    def redirect?
      status.to_i >= 300 && status.to_i < 400
    end

respond_to?(method_name) click to toggle source

Check if method is defined on the body

    # File lib/github_api/response_wrapper.rb, line 132
    def respond_to?(method_name)
      if self.has_key?(method_name.to_s)
        true
      else
        super
      end
    end

server_error?() click to toggle source

    # File lib/github_api/response_wrapper.rb, line 67
    def server_error?
      status.to_i >= 500 && status.to_i < 600
    end

status() click to toggle source

Response status

    # File lib/github_api/response_wrapper.rb, line 51
    def status
      response.status
    end

success?() click to toggle source

    # File lib/github_api/response_wrapper.rb, line 55
    def success?
      response.success?
    end

to_ary() click to toggle source

Convert the ResponseWrapper into an Array

    # File lib/github_api/response_wrapper.rb, line 102
    def to_ary
      body.to_ary
    end

to_hash() click to toggle source

Convert the ResponseWrapper into a Hash

    # File lib/github_api/response_wrapper.rb, line 96
    def to_hash
      body.to_hash
    end

to_s() click to toggle source

Return response body as string

    # File lib/github_api/response_wrapper.rb, line 90
    def to_s
      body.to_s
    end

url() click to toggle source

Request url

    # File lib/github_api/response_wrapper.rb, line 34
    def url
      response.env[:url].to_s
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.