Module: Tanker::Pagination

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

Defined Under Namespace

Modules: Categories Classes: Kaminari, WillPaginate

Class Method Summary collapse

Class Method Details

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



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

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