Module: Pagy::OffsetPaginator
- Defined in:
- lib/pagy/toolbox/paginators/offset.rb
Class Method Summary collapse
Class Method Details
.paginate(collection, options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pagy/toolbox/paginators/offset.rb', line 9 def paginate(collection, ) [:page] ||= [:request].resolve_page [:limit] = [:request].resolve_limit [:count] ||= Countable.get_count(collection, ) pagy = Offset.new(**) records = if collection.instance_of?(Array) collection[pagy.offset, pagy.limit] else pagy.records(collection) end [pagy, records] end |