### Home Classes Methods

### In Files

- lib/github_api/api/actions.rb
- lib/github_api/api.rb

### Parent

Object

### Methods

- ::inherited
- ::new
- #api_methods_in
- #append_arguments
- #arguments
- #process_basic_auth
- #set
- #setup
- #with
- #yield_or_eval

### Included Modules

- Github::Constants
- Github::Authorization
- Github::MimeType
- Github::Connection
- Github::Request
- Github::RateLimit

### 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::API

Core class for api interface operations

### Attributes

current_options[RW]

### Public Class Methods

inherited(klass) click to toggle source

Returns all API public methods for a given class.

    # File lib/github_api/api/actions.rb, line 6
    def self.inherited(klass)
      klass.class_eval         def self.actions          self.new.api_methods_in(#{klass})        end        def actions          api_methods_in(#{klass})        end, __FILE__, __LINE__ + 1
      super
    end

new(options={}, &block) click to toggle source

Create new API

    # File lib/github_api/api.rb, line 41
    def initialize(options={}, &block)
      setup(options)
      yield_or_eval(&block) if block_given?
    end

### Public Instance Methods

api_methods_in(klass) click to toggle source

    # File lib/github_api/api/actions.rb, line 18
    def api_methods_in(klass)
      puts "---"
      (klass.send(:instance_methods, false) - ['actions']).sort.each do |method|
        puts "|--> #{method}"
      end
      klass.included_modules.each do |mod|
        if mod.to_s =~ /#{klass}/
          puts "| \\ #{mod.to_s}"
          mod.instance_methods(false).each do |met|
            puts "|  |--> #{met}"
          end
          puts "| /"
        end
      end
      puts "---"
      nil
    end

append_arguments(method) click to toggle source

    # File lib/github_api/api/actions.rb, line 36
    def append_arguments(method)
      _method = self.method(method)
      if _method.arity == 0
        args = "()"
      elsif _method.arity > 0
        args = "(few)"
      else
        args = "(else)"
      end
      args
    end

arguments(args=(not_set = true), options={}, &block) click to toggle source

Acts as setter and getter for api requests arguments parsing.

Returns Arguments instance.

    # File lib/github_api/api.rb, line 90
    def arguments(args=(not_set = true), options={}, &block)
      if not_set
        @arguments
      else
        @arguments = Arguments.new(self, options).parse(*args, &block)
      end
    end

process_basic_auth(auth) click to toggle source

Extract login and password from basic_auth parameter

    # File lib/github_api/api.rb, line 64
    def process_basic_auth(auth)
      case auth
      when String
        self.login, self.password = auth.split(':', 2)
      when Hash
        self.login    = auth[:login]
        self.password = auth[:password]
      end
    end

set(option, value=(not_set=true), ignore_setter=false, &block) click to toggle source

Set an option to a given value

    # File lib/github_api/api.rb, line 113
    def set(option, value=(not_set=true), ignore_setter=false, &block)
      raise ArgumentError, 'value not set' if block and !not_set
      return self if !not_set and value.nil?

      if not_set
        set_options option
        return self
      end

      if respond_to?("#{option}=") and not ignore_setter
        return __send__("#{option}=", value)
      end

      define_accessors option, value
      self
    end

setup(options={}) click to toggle source

Configure options and process basic authorization

    # File lib/github_api/api.rb, line 53
    def setup(options={})
      options = Github.options.merge(options)
      self.current_options = options
      Configuration.keys.each do |key|
        send("#{key}=", options[key])
      end
      process_basic_auth(options[:basic_auth])
    end

with(args) click to toggle source

Scope for passing request required arguments.

    # File lib/github_api/api.rb, line 100
    def with(args)
      case args
      when Hash
        set args
      when /.*\/.*/
        user, repo = args.split('/')
        set :user => user, :repo => repo
      else
        ::Kernel.raise ArgumentError, 'This api does not support passed in arguments'
      end
    end

yield_or_eval(&block) click to toggle source

    # File lib/github_api/api.rb, line 46
    def yield_or_eval(&block)
      return unless block
      block.arity > 0 ? yield(self) : self.instance_eval(&block)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.