module Folio::WillPaginate::ViewHelpers::LinkRenderer
Public Class Methods
included(klass)
click to toggle source
# File lib/folio/will_paginate/view_helpers/link_renderer.rb, line 42 def self.included(klass) [:prepare, :windowed_links, :total_pages, :rel_value].each do |method| klass.send(:alias_method, :"#{method}_without_folio", method) klass.send(:alias_method, method, :"#{method}_with_folio") end end
Public Instance Methods
prepare_with_folio(collection, options, template)
click to toggle source
# File lib/folio/will_paginate/view_helpers/link_renderer.rb, line 8 def prepare_with_folio(collection, options, template) # 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, template) end
rel_value_with_folio(page)
click to toggle source
# File lib/folio/will_paginate/view_helpers/link_renderer.rb, line 32 def rel_value_with_folio(page) # don't check against mathed out values, just check the values on the # collection rels = [] rels << 'prev' if page == @collection.previous_page rels << 'next' if page == @collection.next_page rels << 'start' if page == @collection.first_page rels.empty? ? nil : rels.join(' ') end
total_pages_with_folio()
click to toggle source
# File lib/folio/will_paginate/view_helpers/link_renderer.rb, line 24 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_links_with_folio()
click to toggle source
# File lib/folio/will_paginate/view_helpers/link_renderer.rb, line 15 def windowed_links_with_folio links = windowed_links_without_folio unless @collection.last_page # the last page is not known, so add a trailing gap links << gap_marker end links end