Module: Esse::WillPaginate::Pagination::SearchQuery

Defined in:
lib/esse/will_paginate/pagination.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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 "    # Define the `paginate` WillPaginate method\n    #\n    # @param [Hash] options\n    # @option options [Integer] :page\n    # @option options [Integer] :per_page\n    # @return [Esse::WillPaginate::SearchQuery]\n    def paginate(options = {})\n      curr_page = ::WillPaginate::PageNumber(options[:page] || 1)\n      limit_val = (options[:per_page] || ::WillPaginate.per_page).to_i\n      offset_val = (curr_page - 1) * limit_val\n      limit(limit_val).offset(offset_val)\n    end\n  RUBY\nend\n", __FILE__, __LINE__ + 1

Instance Method Details

#paginated_resultsObject



24
25
26
27
28
29
# File 'lib/esse/will_paginate/pagination.rb', line 24

def paginated_results
  page = (offset_value / limit_value.to_f).ceil + 1
  ::WillPaginate::Collection.create(page, limit_value, response.total) do |pager|
    pager.replace response.hits
  end
end