Module: Grape::Kaminari::HelperMethods
- Extended by:
- API::Helpers
- Defined in:
- lib/grape/kaminari.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#paginate(collection, without_count: false) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/grape/kaminari.rb', line 36 def paginate(collection, without_count: false) coll = collection.page(params[:page].to_i) .per(params[:per_page].to_i) .padding(params[:offset].to_i) coll = coll.without_count if without_count && coll.respond_to?(:without_count) unless without_count header 'X-Total', coll.total_count.to_s header 'X-Total-Pages', coll.total_pages.to_s end header 'X-Per-Page', coll.limit_value.to_s header 'X-Page', coll.current_page.to_s header 'X-Next-Page', coll.next_page.to_s header 'X-Prev-Page', coll.prev_page.to_s header 'X-Offset', params[:offset].to_s coll end |