class Westfield::Paginator
Attributes
page_info[R]
Public Class Methods
config()
click to toggle source
Global settings for Westfield::Paginator
# File lib/westfield_paginator/config.rb, line 15 def self.config @config end
configure() { |config ||= configuration| ... }
click to toggle source
Configures global settings for pagination
Westfield::Paginator.configure do |config| config.default_per_page = 10 end
# File lib/westfield_paginator/config.rb, line 10 def self.configure(&block) yield @config ||= Westfield::Paginator::Configuration.new end
new(records, page: nil, per_page: nil, max_per_page: nil)
click to toggle source
# File lib/westfield_paginator/paginator.rb, line 6 def initialize(records, page: nil, per_page: nil, max_per_page: nil) @page_info = Westfield::PageInfo.new(page: page, per_page: per_page, max_per_page: max_per_page) if records.is_a? Array @records = Kaminari.paginate_array(records) else @records = records end end
Public Instance Methods
current_page()
click to toggle source
# File lib/westfield_paginator/paginator.rb, line 24 def current_page paginated_records.current_page end
meta()
click to toggle source
# File lib/westfield_paginator/paginator.rb, line 20 def meta PaginatorMeta.new(self).as_json end
paginated_records()
click to toggle source
# File lib/westfield_paginator/paginator.rb, line 16 def paginated_records @paginated ||= @records.page(page_info.page).per(page_info.per_page) end
per_page()
click to toggle source
# File lib/westfield_paginator/paginator.rb, line 28 def per_page page_info.per_page end
total_count()
click to toggle source
# File lib/westfield_paginator/paginator.rb, line 36 def total_count paginated_records.total_count end
total_pages()
click to toggle source
# File lib/westfield_paginator/paginator.rb, line 32 def total_pages paginated_records.total_pages end