Commit 4008b724b3e74e37476d7b8eac7efa2725464086
1 parent
400664f1
Exists in
master
and in
21 other branches
Better results
Showing
2 changed files
with
11 additions
and
5 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -338,13 +338,12 @@ module Searchkick |
338 | 338 | end |
339 | 339 | |
340 | 340 | opts = { |
341 | + page: @page, | |
342 | + per_page: @per_page, | |
341 | 343 | load: @load, |
342 | 344 | includes: options[:include] || options[:includes] |
343 | 345 | } |
344 | - results = Searchkick::Results.new(searchkick_klass, response, opts) | |
345 | - results.current_page = @page | |
346 | - results.per_page = @per_page | |
347 | - results | |
346 | + Searchkick::Results.new(searchkick_klass, response, opts) | |
348 | 347 | end |
349 | 348 | |
350 | 349 | private | ... | ... |
lib/searchkick/results.rb
... | ... | @@ -4,7 +4,6 @@ module Searchkick |
4 | 4 | extend Forwardable |
5 | 5 | |
6 | 6 | attr_reader :klass, :response, :options |
7 | - attr_accessor :current_page, :per_page | |
8 | 7 | |
9 | 8 | def_delegators :results, :each, :empty?, :size, :slice, :[], :to_ary |
10 | 9 | |
... | ... | @@ -65,6 +64,14 @@ module Searchkick |
65 | 64 | response["hits"]["total"] |
66 | 65 | end |
67 | 66 | |
67 | + def current_page | |
68 | + options[:page] | |
69 | + end | |
70 | + | |
71 | + def per_page | |
72 | + options[:per_page] | |
73 | + end | |
74 | + | |
68 | 75 | def total_pages |
69 | 76 | (total_count / per_page.to_f).ceil |
70 | 77 | end | ... | ... |