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
30 31 32 33 34 35 36 37 |
# File 'app/queries/workarea/search/pagination.rb', line 30 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
17 18 19 |
# File 'app/queries/workarea/search/pagination.rb', line 17 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 |
# File 'app/queries/workarea/search/pagination.rb', line 9 def per_page params[:per_page].presence || Workarea.config.per_page end |
#results ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/queries/workarea/search/pagination.rb', line 21 def results @paged_results ||= PagedArray.from( super, page, per_page, total ) end |
#size ⇒ Object
13 14 15 |
# File 'app/queries/workarea/search/pagination.rb', line 13 def size super || per_page end |