lib/quirky-api/response/pagination.rb
def pagination_headers(objects, options = {})
        raise ArgumentError.new('options[:url] must be provided') unless options[:url]

        options = self.pagination_options.merge(options)
        url = options.delete(:url)
        link_headers = []

        if options[:page].to_i > 1
          link_headers << link_header(paginated_url(url, page: 1), 'first')
        end
        if objects.next_page
          link_headers << link_header(paginated_url(url, page: objects.next_page), 'next')
        end
        if objects.previous_page
          link_headers << link_header(paginated_url(url, page: objects.previous_page), 'prev')
        end
        if objects.total_pages != options[:page].to_i
          link_headers << link_header(paginated_url(url, page: objects.total_pages), 'last')
        end

        headers['Link'] = link_headers.join(', ') if link_headers.size
        headers['Total'] = objects.total_entries.to_s
      end
# Sets Hypermedia-style Link headers for a collection of paginated objects.
# See: https://developer.github.com/guides/traversing-with-pagination/
#
# @param objects [Object] A collection of objects that have been paginated by will_paginate.
# @param options [Hash] A hash of options that will overwrite +pagination_options+.
# @param options[:url] [Array] An array of URL options that will be passed to +polymorphic_url+.
#
# @see #pagination_options
# @see {http://api.rubyonrails.org/classes/ActionDispatch/Routing/PolymorphicRoutes.html#method-i-polymorphic_url polymorphic_url}
#
Sets Hypermedia-style Link headers for a collection of paginated objects.
Sets Hypermedia - style Link headers for a collection of paginated objects .
def pagination_headers(objects, options = {})
        raise ArgumentError.new('options[:url] must be provided') unless options[:url]
        options = self.pagination_options.merge(options)
        url = options.delete(:url)
        link_headers = []
        if options[:page].to_i > 1
          link_headers << link_header(paginated_url(url, page: 1), 'first')
        end
        if objects.next_page
          link_headers << link_header(paginated_url(url, page: objects.next_page), 'next')
        end
        if objects.previous_page
          link_headers << link_header(paginated_url(url, page: objects.previous_page), 'prev')
        end
        if objects.total_pages != options[:page].to_i
          link_headers << link_header(paginated_url(url, page: objects.total_pages), 'last')
        end
        headers['Link'] = link_headers.join(', ') if link_headers.size
        headers['Total'] = objects.total_entries.to_s
      end
def pagination_headers ( objects , options = { } ) raise ArgumentError . new ( 'options[:url] must be provided' ) unless options [ :url ] options = self . pagination_options . merge ( options ) url = options . delete ( :url ) link_headers = [ ] if options [ :page ] . to_i > 1 link_headers << link_header ( paginated_url ( url , page : 1 ) , 'first' ) end if objects . next_page link_headers << link_header ( paginated_url ( url , page : objects . next_page ) , 'next' ) end if objects . previous_page link_headers << link_header ( paginated_url ( url , page : objects . previous_page ) , 'prev' ) end if objects . total_pages != options [ :page ] . to_i link_headers << link_header ( paginated_url ( url , page : objects . total_pages ) , 'last' ) end headers [ 'Link' ] = link_headers . join ( ', ' ) if link_headers . size headers [ 'Total' ] = objects . total_entries . to_s end
Sets Hypermedia-style Link headers for a collection of paginated objects.
Sets Hypermedia - style Link headers for a collection of paginated objects .
objects
A collection of objects that have been paginated by will_paginate.
A collection of objects that have been paginated by will_paginate .
options
[Array] An array of URL options that will be passed to +polymorphic_url+.
[ Array ] An array of URL options that will be passed to + polymorphic_url + .
see
None
see
None