Sha256: 921cbac837e04326e35a2fac52c8d4385b98be2a1d2395b16afec0e72a96fe90
Contents?: true
Size: 687 Bytes
Versions: 6
Compression:
Stored size: 687 Bytes
Contents
module Sequel::Plugins::LuxSimplePaginate module DatasetMethods def page size: 20, param: :page, page: nil, count: nil page = (page || Lux.current.request.params[param]).to_i page = 1 if page < 1 # ret = paginate(page, size).all ret = offset((page-1) * size).limit(size+1).all has_next = ret.length == size + 1 ret.pop if has_next ret.define_singleton_method(:paginate_param) do; param ;end ret.define_singleton_method(:paginate_page) do; page; end ret.define_singleton_method(:paginate_next) do; has_next; end ret end end end Sequel::Model.db.extension :pagination Sequel::Model.plugin :lux_simple_paginate
Version data entries
6 entries across 6 versions & 1 rubygems