Sha256: 92510620d2d5157cfdd87ffde617f1adc88e0bdc6c08afbc24b9d04ffaff76d3
Contents?: true
Size: 877 Bytes
Versions: 31
Compression:
Stored size: 877 Bytes
Contents
module Workarea module Search module Pagination def page tmp = params[:page].present? ? params[:page].to_i : 1 tmp > 0 ? tmp : 1 end def per_page params[:per_page].presence || Workarea.config.per_page end def size super || per_page end def from size * (page - 1) end def results @paged_results ||= PagedArray.from( super, page, per_page, total ) end def each_by(by, &block) i = 0 while (results = get_each_by_results(by, i)) && results.present? results.each { |result| yield(result) } i += 1 end end private def get_each_by_results(by, i) self.class.new(params.merge(page: i + 1, per_page: by)).results end end end end
Version data entries
31 entries across 31 versions & 1 rubygems