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, #options

Instance Method Summary collapse

Methods inherited from Wrapper

[], #[], #frontend, #frontend=, #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



44
45
46
47
48
49
50
# File 'lib/gh/pagination.rb', line 44

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



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

def modify_response(response)
  return response unless response.respond_to? :to_ary and response.headers['link'] =~ /<([^>]+)>;\s*rel=\"next\"/
  Paginated.new(response, $1, self)
end