Module: Folio::WillPaginate::ViewHelpers::LinkRendererBase

Defined in:
lib/folio/will_paginate/view_helpers/link_renderer_base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



33
34
35
36
37
38
# File 'lib/folio/will_paginate/view_helpers/link_renderer_base.rb', line 33

def self.included(klass)
  [:prepare, :windowed_page_numbers, :total_pages].each do |method|
    klass.send(:alias_method, :"#{method}_without_folio", method)
    klass.send(:alias_method, method, :"#{method}_with_folio")
  end
end

Instance Method Details

#prepare_with_folio(collection, options) ⇒ Object



7
8
9
10
11
12
# File 'lib/folio/will_paginate/view_helpers/link_renderer_base.rb', line 7

def prepare_with_folio(collection, options)
  # only include page_links if we're in a collection with ordinal
  # pages; otherwise stick to just prev/next.
  options = options.merge(page_links: false) unless collection.ordinal_pages?
  prepare_without_folio(collection, options)
end

#total_pages_with_folioObject



25
26
27
28
29
30
31
# File 'lib/folio/will_paginate/view_helpers/link_renderer_base.rb', line 25

def total_pages_with_folio
  # the collection may not have a known last page. if so, there must be
  # a next page; count that as the last known page. it's ok to use
  # these page identifiers as a page count because (after fixing
  # LinkRenderer) it's only called when ordinal_pages is true.
  @collection.last_page || @collection.next_page
end

#windowed_page_numbers_with_folioObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/folio/will_paginate/view_helpers/link_renderer_base.rb', line 14

def windowed_page_numbers_with_folio
  page_numbers = windowed_page_numbers_without_folio
  unless @collection.last_page
    # the last page is not known, so add a trailing gap (it won't
    # already be there, because the right range during the super call
    # won't exist).
    page_numbers << :gap
  end
  page_numbers
end