module Tire::Results::Pagination

Adds support for WillPaginate and Kaminari

Public Class Methods

default_per_page() click to toggle source
# File lib/tire/results/pagination.rb, line 8
def default_per_page
  10
end

Public Instance Methods

current_page() click to toggle source
# File lib/tire/results/pagination.rb, line 25
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/tire/results/pagination.rb, line 57
def first_page?
  current_page == 1
end
last_page?() click to toggle source
# File lib/tire/results/pagination.rb, line 61
def last_page?
  current_page == total_pages
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 37
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 41
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 45
def out_of_bounds?
  current_page > total_pages
end
Also aliased as: out_of_range?
out_of_range?() click to toggle source
Alias for: out_of_bounds?
per_page() click to toggle source
# File lib/tire/results/pagination.rb, line 17
def per_page
  (@options[:per_page] || @options[:size] || default_per_page ).to_i
end
Also aliased as: limit_value
previous_page() click to toggle source
# File lib/tire/results/pagination.rb, line 33
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 13
def total_entries
  @total
end
Also aliased as: total_count
total_pages() click to toggle source
# File lib/tire/results/pagination.rb, line 21
def total_pages
  ( @total.to_f / per_page ).ceil
end
Also aliased as: num_pages