class AlgoliaSearch::Pagination::Kaminari
Public Class Methods
Source
# File lib/algoliasearch/pagination/kaminari.rb, line 26 def create(results, total_hits, options = {}) offset = ((options[:page] - 1) * options[:per_page]) array = new results, :offset => offset, :limit => options[:per_page], :total_count => total_hits if array.empty? and !results.empty? # since Kaminari 0.16.0, you need to pad the results with nil values so it matches the offset param # otherwise you'll get an empty array: https://github.com/amatsuda/kaminari/commit/29fdcfa8865f2021f710adaedb41b7a7b081e34d results = ([nil] * offset) + results array = new results, :offset => offset, :limit => options[:per_page], :total_count => total_hits end array end
Source
# File lib/algoliasearch/pagination/kaminari.rb, line 11 def initialize(array, options) super(array, **options) end
Calls superclass method
Public Instance Methods
Source
# File lib/algoliasearch/pagination/kaminari.rb, line 15 def limit(num) # noop self end
Source
# File lib/algoliasearch/pagination/kaminari.rb, line 20 def offset(num) # noop self end