Module: Katalyst::Tables::Collection::Pagination
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/katalyst/tables/collection/pagination.rb
Overview
Adds pagination support for a collection.
Pagination will be applied if the collection is configured to paginate by either specifying ‘config.paginate = true` or passing `paginate: true` to the initializer.
If the value given to ‘paginate` is a hash, it will be passed to the `pagy` gem as options.
If ‘page` is present in params it will be passed to pagy.
Defined Under Namespace
Classes: Paginate
Instance Method Summary collapse
Instance Method Details
#initialize(paginate: config.paginate) ⇒ Object
27 28 29 30 31 |
# File 'app/models/concerns/katalyst/tables/collection/pagination.rb', line 27 def initialize(paginate: config.paginate, **) super(**) @paginate = paginate.freeze end |
#paginate? ⇒ Boolean
33 34 35 |
# File 'app/models/concerns/katalyst/tables/collection/pagination.rb', line 33 def paginate? !!@paginate end |
#paginate_options ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/concerns/katalyst/tables/collection/pagination.rb', line 37 def opts = @paginate.is_a?(Hash) ? @paginate : {} opts = opts.dup if PagyNavComponent.pagy_legacy? opts[:anchor_string] ||= "data-turbo-action=\"replace\"" end opts end |