Class: Grape::Pagy::Wrapper
- Inherits:
-
Struct
- Object
- Struct
- Grape::Pagy::Wrapper
- Includes:
- Pagy::Backend
- Defined in:
- lib/grape/pagy.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#request ⇒ Object
Returns the value of attribute request.
Instance Method Summary collapse
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params
12 13 14 |
# File 'lib/grape/pagy.rb', line 12 def params @params end |
#request ⇒ Object
Returns the value of attribute request
12 13 14 |
# File 'lib/grape/pagy.rb', line 12 def request @request end |
Instance Method Details
#paginate(collection, using: nil, **opts, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/grape/pagy.rb', line 15 def paginate(collection, using: nil, **opts, &block) opts = pagy_countless_get_vars(nil, opts) using ||= if collection.respond_to?(:arel_table) :arel elsif collection.is_a?(Array) :array end method = [:pagy, using].compact.join('_') page, scope = send(method, collection, **opts) pagy_headers(page).each(&block) scope end |