Module: AlgoliaSearch::Pagination

Defined in:
lib/algoliasearch/pagination.rb,
lib/algoliasearch/pagination/kaminari.rb,
lib/algoliasearch/pagination/will_paginate.rb

Defined Under Namespace

Classes: Kaminari, WillPaginate

Class Method Summary collapse

Class Method Details

.create(results, total_hits, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/algoliasearch/pagination.rb', line 7

def self.create(results, total_hits, options = {})
  return results if AlgoliaSearch.configuration[:pagination_backend].nil?
  begin
    backend = AlgoliaSearch.configuration[:pagination_backend].to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } # classify pagination backend name
    page = Object.const_get(:AlgoliaSearch).const_get(:Pagination).const_get(backend).create(results, total_hits, options)
    page
  rescue NameError
    raise(BadConfiguration, "Unknown pagination backend")
  end
end