Module: Workarea::Search::Pagination
- Included in:
- AdminSearchQueryWrapper, AdminAssets, AdminCategories, AdminDiscounts, AdminFulfillmentSkus, AdminInventorySkus, AdminOrders, AdminPages, AdminPaymentTransactions, AdminPricingSkus, AdminProducts, AdminReleasables, AdminReleases, AdminSearch, AdminSegments, AdminUsers, CategoryBrowse, HelpSearch, ProductSearch, RelatedHelp, TaxonomySitemap
- Defined in:
- app/queries/workarea/search/pagination.rb
Instance Method Summary collapse
- #each_by(by, &block) ⇒ Object
- #from ⇒ Object
- #page ⇒ Object
- #per_page ⇒ Object
- #results ⇒ Object
- #size ⇒ Object
Instance Method Details
#each_by(by, &block) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/queries/workarea/search/pagination.rb', line 33 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 |
#from ⇒ Object
20 21 22 |
# File 'app/queries/workarea/search/pagination.rb', line 20 def from size * (page - 1) end |
#page ⇒ Object
4 5 6 7 |
# File 'app/queries/workarea/search/pagination.rb', line 4 def page tmp = params[:page].present? ? params[:page].to_i : 1 tmp > 0 ? tmp : 1 end |
#per_page ⇒ Object
9 10 11 12 13 14 |
# File 'app/queries/workarea/search/pagination.rb', line 9 def per_page return Workarea.config.per_page if params[:per_page].blank? tmp = params[:per_page].to_i tmp > 0 ? tmp : Workarea.config.per_page end |
#results ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/queries/workarea/search/pagination.rb', line 24 def results @paged_results ||= PagedArray.from( super, page, per_page, total ) end |
#size ⇒ Object
16 17 18 |
# File 'app/queries/workarea/search/pagination.rb', line 16 def size super || per_page end |