module Tire::Results::Pagination

Adds support for WillPaginate and Kaminari

Public Instance Methods

current_page() click to toggle source
# File lib/tire/results/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
limit_value() click to toggle source

Kaminari support

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