class Footrest::Pagination
Constants
- Links
Public Instance Methods
find_link(header, rel)
click to toggle source
# File lib/footrest/pagination.rb, line 29 def find_link(header, rel) link = ::LinkHeader.parse(header).links.find{ |link| link['rel'] == rel } link.to_a.first if link end
on_complete(response)
click to toggle source
# File lib/footrest/pagination.rb, line 15 def on_complete(response) if response[:response_headers] if link_header = response[:response_headers][:link] links = Links.new %w(prev next first last current).each do |page| link = find_link(link_header, page) response["#{page}_page".to_sym] = link links.public_send("#{ page }=", link) end response[:pagination_links] = links end end end