Module: Apress::Api::ApiController::PaginationHelper
- Defined in:
- lib/apress/api/api_controller/pagination_helper.rb
Class Method Summary collapse
Class Method Details
.headers(collection, url) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/apress/api/api_controller/pagination_helper.rb', line 6 def self.headers(collection, url) result = {} result['X-Total-Count'] = collection.total_entries.to_s result['X-Total-Pages'] = collection.total_pages.to_s result['X-Per-Page'] = collection.per_page.to_s result['X-Page'] = collection.current_page.to_s numbers = page_numbers(collection) links = header_link_values(url, numbers) result['Link'] = links.join(', ') if links.present? result end |