Sha256: 19729486e107df41109ac98f77953fc609ee796023dd99ae61a142867c234b7a

Contents?: true

Size: 775 Bytes

Versions: 1

Compression:

Stored size: 775 Bytes

Contents

module Github
  module PagedRequest
    include Github::Constants

    extend self

    FIRST_PAGE = 1

    PER_PAGE = 25

    class << self
      attr_accessor :page, :per_page
    end

    def default_page_size
      Github.api_client.per_page ? Github.api_client.per_page : PER_PAGE
    end

    def default_page
      Github.api_client.page ? Github.api_client.page : FIRST_PAGE
    end

    def page_request(path, params={})
      params[PARAM_PER_PAGE] = default_page_size unless params[PARAM_PER_PAGE]
      params[PARAM_PAGE] = default_page unless params[PARAM_PAGE]

      Github::PagedRequest.page = params[PARAM_PAGE]
      Github::PagedRequest.per_page = params[PARAM_PER_PAGE]

      Github.api_client.get path, params
    end

  end # PagedRequest
end # Github

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github_api-0.4.0 lib/github_api/paged_request.rb