Module: SunspotWithKaminari::Search::AbstractSearchInstanceMethods
- Defined in:
- lib/sunspot_with_kaminari.rb
Instance Method Summary collapse
- #any? ⇒ Boolean
-
#current_page ⇒ Object
Returns.
- #empty? ⇒ Boolean
-
#limit_value ⇒ Object
Returns.
- #page(current_page) ⇒ Object
-
#total_pages ⇒ Object
Returns.
Instance Method Details
#any? ⇒ Boolean
34 35 36 |
# File 'lib/sunspot_with_kaminari.rb', line 34 def any? total > 0 end |
#current_page ⇒ Object
Returns
- Integer
-
Current page number
10 11 12 |
# File 'lib/sunspot_with_kaminari.rb', line 10 def current_page @query.page end |
#empty? ⇒ Boolean
30 31 32 |
# File 'lib/sunspot_with_kaminari.rb', line 30 def empty? total == 0 end |
#limit_value ⇒ Object
Returns
- Integer
-
Number of records displayed per page
26 27 28 |
# File 'lib/sunspot_with_kaminari.rb', line 26 def limit_value @query.per_page || Kaminari.config.default_per_page end |
#page(current_page) ⇒ Object
38 39 40 41 |
# File 'lib/sunspot_with_kaminari.rb', line 38 def page(current_page) query.paginate(current_page, nil) self.execute.results end |
#total_pages ⇒ Object
Returns
- Integer
-
Total number of pages for matching documents
18 19 20 |
# File 'lib/sunspot_with_kaminari.rb', line 18 def total_pages (total.to_f / @query.per_page).ceil end |