Sha256: 5e37e763f4ceb178ce71a11f3d64c14d620b7a7c29d63604f4f280ea310adb79
Contents?: true
Size: 1.07 KB
Versions: 15
Compression:
Stored size: 1.07 KB
Contents
module Spree module Api module V2 module CollectionOptionsHelpers def collection_links(collection) { self: request.original_url, next: pagination_url(collection.next_page || collection.total_pages), prev: pagination_url(collection.prev_page || 1), last: pagination_url(collection.total_pages), first: pagination_url(1) } end def collection_meta(collection) { count: collection.size, total_count: collection.total_count, total_pages: collection.total_pages } end # leaving this method in public scope so it's still possible to modify # those params to support non-standard non-JSON API parameters def collection_permitted_params params.permit(:format, :page, :per_page, :sort, :include, :fields, filter: {}) end private def pagination_url(page) url_for(collection_permitted_params.merge(page: page)) end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems