class Folio::Enumerable::Decorator
Constants
- METHODS
Public Instance Methods
build_page()
click to toggle source
just fill a typical ordinal page
# File lib/folio/core_ext/enumerable.rb, line 8 def build_page ::Folio::Ordinal::Page.create end
default_per_page()
click to toggle source
things that already included Enumerable
won't have extended the PerPage
, so the instance's default default_per_page
method looking at self.class.per_page won't work. point it back at Folio.per_page
# File lib/folio/core_ext/enumerable.rb, line 25 def default_per_page Folio.per_page end
fill_page(page)
click to toggle source
fill by taking the appropriate slice out of the enumerable. if the slice is empty and it's not the first page, it's invalid
# File lib/folio/core_ext/enumerable.rb, line 14 def fill_page(page) slice = self.each_slice(page.per_page).first(page.current_page)[page.current_page-1] || [] raise ::Folio::InvalidPage if slice.empty? && page.current_page != page.first_page page.replace slice page end