7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/esse/will_paginate/pagination.rb', line 7
def self.included(base)
base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
# Define the `paginate` WillPaginate method
#
# @param [Hash] options
# @option options [Integer] :page
# @option options [Integer] :per_page
# @return [Esse::WillPaginate::SearchQuery]
def paginate(options = {})
curr_page = ::WillPaginate::PageNumber(options[:page] || 1)
limit_val = (options[:per_page] || ::WillPaginate.per_page).to_i
offset_val = (curr_page - 1) * limit_val
limit(limit_val).offset(offset_val)
end
RUBY
end
|