Sha256: 24987debe19aeaefe47219505fee105be946cb413d7f181ccd5204c7032bc314
Contents?: true
Size: 574 Bytes
Versions: 1
Compression:
Stored size: 574 Bytes
Contents
# frozen_string_literal: true require 'active_support/concern' require_relative "next-pageable/version" require_relative "next-pageable/page" module NextPageable extend ActiveSupport::Concern class_methods do def page(page, pagesize: 15) collection = self .limit(pagesize+1) .offset(page.to_i*pagesize) if collection.length > pagesize next_page_index = page.to_i+1 collection = collection[0...-1] end return Page.new(collection: collection, next_page_index: next_page_index) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
next-pageable-0.1.3 | lib/next-pageable.rb |