module Github::PagedRequest

A module that adds http get request to response pagination

Constants

FIRST_PAGE
NOT_FOUND
PER_PAGE

Public Instance Methods

default_page() click to toggle source
# File lib/github_api/paged_request.rb, line 21
def default_page
  current_api.page ? current_api.page : FIRST_PAGE
end
default_page_size() click to toggle source

Check if current api instance has default per_page param set, otherwise use global default.

# File lib/github_api/paged_request.rb, line 17
def default_page_size
  current_api.per_page ? current_api.per_page : PER_PAGE
end
page_request(path, params={}) click to toggle source

Perform http get request with pagination parameters

# File lib/github_api/paged_request.rb, line 27
def page_request(path, params={})
  if params[PARAM_PER_PAGE] == NOT_FOUND
    params[PARAM_PER_PAGE] = default_page_size
  end
  if params[PARAM_PAGE] && params[PARAM_PAGE] == NOT_FOUND
    params[PARAM_PAGE] = default_page
  end

  current_api.get_request(path, ParamsHash.new(params))
end