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
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
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
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?
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_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