Module: SunspotWithKaminari::Search::AbstractSearchInstanceMethods

Defined in:
lib/sunspot_with_kaminari.rb

Instance Method Summary collapse

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/sunspot_with_kaminari.rb', line 34

def any?
  total > 0
end

#current_pageObject

Returns

Integer

Current page number



10
11
12
# File 'lib/sunspot_with_kaminari.rb', line 10

def current_page
  @query.page
end

#empty?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/sunspot_with_kaminari.rb', line 30

def empty?
  total == 0
end

#limit_valueObject

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_pagesObject

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