Class: GH::Pagination

Inherits:
Wrapper show all
Defined in:
lib/gh/pagination.rb

Defined Under Namespace

Classes: Paginated

Instance Attribute Summary

Attributes inherited from Wrapper

#backend, #frontend, #options

Instance Method Summary collapse

Methods inherited from Wrapper

#[], [], double_dispatch, #generate_response, #initialize, #inspect, #load, #prefixed, #reset, wraps

Constructor Details

This class inherits a constructor from GH::Wrapper

Instance Method Details

#fetch_resource(key) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/gh/pagination.rb', line 50

def fetch_resource(key)
  url = frontend.full_url(key)
  params = url.query_values || {}
  params['per_page'] ||= 100
  url.query_values = params
  super url.request_uri
end

#modify_response(response) ⇒ Object



58
59
60
61
62
# File 'lib/gh/pagination.rb', line 58

def modify_response(response)
  return response unless response.respond_to?(:to_ary) && response.headers['link'] =~ (/<([^>]+)>;\s*rel="next"/)

  Paginated.new(response, ::Regexp.last_match(1), self)
end