Sha256: c45b851d4ef6be16113f09e6a75f52978c3675b72e0e850d1be76ad516bc2aec
Contents?: true
Size: 986 Bytes
Versions: 3
Compression:
Stored size: 986 Bytes
Contents
module Kaminari module PageScopeMethods # Specify the <tt>per_page</tt> value for the preceding <tt>page</tt> scope # Model.page(3).per(10) def per(num) if (n = num.to_i) <= 0 self elsif max_per_page && max_per_page < n limit(max_per_page).offset(offset_value / limit_value * max_per_page) else limit(n).offset(offset_value / limit_value * n) end end def padding(num) offset(offset_value + num.to_i) end # Total number of pages def total_pages (total_count.to_f / limit_value).ceil end #FIXME for compatibility. remove num_pages at some time in the future alias num_pages total_pages # Current page number def current_page (offset_value / limit_value) + 1 end # First page of the collection ? def first_page? current_page == 1 end # Last page of the collection? def last_page? current_page >= total_pages end end end
Version data entries
3 entries across 3 versions & 2 rubygems