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

        options = self.cursor_pagination_options.merge(options)
        url = options.delete(:url)

        link_headers = []
        link_headers << link_header(paginated_url(url, cursor: next_cursor), 'next') if next_cursor
        link_headers << link_header(paginated_url(url, cursor: prev_cursor), 'prev') if prev_cursor

        headers['Link'] = link_headers.join(', ') if !link_headers.empty?
        headers['Total'] = objects.count.to_s
      end
# Sets Hypermedia-style Link headers for a collection of cursor-based paginated objects.
#
# @param objects [Object] The unscoped object(s) to paginate. Do not pass the same set of objects returned by +paginate_with_cursor+, the total will not be calculated correctly using those.
# @param next_cursor [Integer] The next_cursor returned by +paginate_with_cursor+.
# @param prev_cursor [Integer] The prev_cursor returned by +paginate_with_cursor+.
# @param options [Hash] A hash of options that will overwrite +cursor_pagination_options+.
# @param options[:url] [Array] An array of URL options that will be passed to +polymorphic_url+.
#
# @see #paginate_with_cursor
# @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 cursor-based paginated objects.
Sets Hypermedia - style Link headers for a collection of cursor - based paginated objects .
def cursor_pagination_headers(objects, next_cursor = nil, prev_cursor = nil, options = {})
        raise ArgumentError.new('options[:url] must be provided') unless options[:url]
        options = self.cursor_pagination_options.merge(options)
        url = options.delete(:url)
        link_headers = []
        link_headers << link_header(paginated_url(url, cursor: next_cursor), 'next') if next_cursor
        link_headers << link_header(paginated_url(url, cursor: prev_cursor), 'prev') if prev_cursor
        headers['Link'] = link_headers.join(', ') if !link_headers.empty?
        headers['Total'] = objects.count.to_s
      end
def cursor_pagination_headers ( objects , next_cursor = nil , prev_cursor = nil , options = { } ) raise ArgumentError . new ( 'options[:url] must be provided' ) unless options [ :url ] options = self . cursor_pagination_options . merge ( options ) url = options . delete ( :url ) link_headers = [ ] link_headers << link_header ( paginated_url ( url , cursor : next_cursor ) , 'next' ) if next_cursor link_headers << link_header ( paginated_url ( url , cursor : prev_cursor ) , 'prev' ) if prev_cursor headers [ 'Link' ] = link_headers . join ( ', ' ) if ! link_headers . empty? headers [ 'Total' ] = objects . count . to_s end
Sets Hypermedia-style Link headers for a collection of cursor-based paginated objects.
Sets Hypermedia - style Link headers for a collection of cursor - based paginated objects .
objects
The unscoped object(s) to paginate. Do not pass the same set of objects returned by +paginate_with_cursor+, the total will not be calculated correctly using those.
The unscoped object ( s ) to paginate . Do not pass the same set of objects returned by + paginate_with_cursor + the total will not be calculated correctly using those .
next_cursor
The next_cursor returned by +paginate_with_cursor+.
The next_cursor returned by + paginate_with_cursor + .
prev_cursor
The prev_cursor returned by +paginate_with_cursor+.
The prev_cursor returned by + paginate_with_cursor + .
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