module Mongoid::Elasticsearch::Pagination

Adds support for WillPaginate and Kaminari

Public Instance Methods

current_page() click to toggle source
# File lib/mongoid/elasticsearch/pagination.rb, line 20
def current_page
  if @options[:page]
    @options[:page].to_i
  else
    (per_page + @options[:from].to_i) / per_page
  end
end
first_page?() click to toggle source
# File lib/mongoid/elasticsearch/pagination.rb, line 52
def first_page?
  current_page == 1
end
last_page?() click to toggle source
# File lib/mongoid/elasticsearch/pagination.rb, line 56
def last_page?
  total_pages == 0 || current_page == total_pages
end
limit_value()

Kaminari support

Alias for: per_page
next_page() click to toggle source
# File lib/mongoid/elasticsearch/pagination.rb, line 32
def next_page
  current_page < total_pages ? (current_page + 1) : nil
end
num_pages()
Alias for: total_pages
offset() click to toggle source
# File lib/mongoid/elasticsearch/pagination.rb, line 36
def offset
  per_page * (current_page - 1)
end
Also aliased as: offset_value
offset_value()
Alias for: offset
out_of_bounds?() click to toggle source
# File lib/mongoid/elasticsearch/pagination.rb, line 40
def out_of_bounds?
  current_page > total_pages
end
Also aliased as: out_of_range?
out_of_range?()
Alias for: out_of_bounds?
per_page() click to toggle source
# File lib/mongoid/elasticsearch/pagination.rb, line 12
def per_page
  (@options[:per_page] || @options[:per] || @options[:size] || 10 ).to_i
end
Also aliased as: limit_value
previous_page() click to toggle source
# File lib/mongoid/elasticsearch/pagination.rb, line 28
def previous_page
  current_page > 1 ? (current_page - 1) : nil
end
total_count()
Alias for: total_entries
total_entries() click to toggle source
# File lib/mongoid/elasticsearch/pagination.rb, line 8
def total_entries
  total
end
Also aliased as: total_count
total_pages() click to toggle source
# File lib/mongoid/elasticsearch/pagination.rb, line 16
def total_pages
  ( total.to_f / per_page ).ceil
end
Also aliased as: num_pages