Class: Grape::Pagination::Paginator
- Inherits:
-
Object
- Object
- Grape::Pagination::Paginator
- Extended by:
- Forwardable
- Defined in:
- lib/grape/pagination/paginator.rb
Constant Summary collapse
- TOTAL_HEADER =
'X-Total'.freeze
- LINK_HEADER =
'Link'.freeze
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(endpoint, collection, options = {}) ⇒ Paginator
constructor
A new instance of Paginator.
- #paginate ⇒ Object
Constructor Details
#initialize(endpoint, collection, options = {}) ⇒ Paginator
Returns a new instance of Paginator.
16 17 18 19 20 |
# File 'lib/grape/pagination/paginator.rb', line 16 def initialize(endpoint, collection, = {}) @endpoint = endpoint @collection = collection @options = end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
9 10 11 |
# File 'lib/grape/pagination/paginator.rb', line 9 def collection @collection end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
8 9 10 |
# File 'lib/grape/pagination/paginator.rb', line 8 def endpoint @endpoint end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/grape/pagination/paginator.rb', line 10 def @options end |
Class Method Details
.paginate(*args) ⇒ Object
12 13 14 |
# File 'lib/grape/pagination/paginator.rb', line 12 def self.paginate(*args) new(*args).paginate end |
Instance Method Details
#paginate ⇒ Object
22 23 24 25 |
# File 'lib/grape/pagination/paginator.rb', line 22 def paginate header LINK_HEADER, LinkHeader.new(request.url, page_params).to_rfc5988 collection.paginate(page_params) end |