Class: Folio::Enumerable::Decorator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Folio::Enumerable::Decorator
- Includes:
- Ordinal
- Defined in:
- lib/folio/core_ext/enumerable.rb
Constant Summary collapse
- METHODS =
self.instance_methods - SimpleDelegator.instance_methods
Constants included from Folio
Instance Method Summary collapse
-
#build_page ⇒ Object
just fill a typical ordinal page.
-
#default_per_page ⇒ Object
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.
-
#fill_page(page) ⇒ Object
fill by taking the appropriate slice out of the enumerable.
Methods included from Ordinal
Methods included from Folio
#configure_pagination, #paginate
Methods included from PerPageIncluder
Methods included from PerPage
Instance Method Details
#build_page ⇒ Object
just fill a typical ordinal page
8 9 10 |
# File 'lib/folio/core_ext/enumerable.rb', line 8 def build_page ::Folio::Ordinal::Page.create end |
#default_per_page ⇒ Object
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
25 26 27 |
# File 'lib/folio/core_ext/enumerable.rb', line 25 def default_per_page Folio.per_page end |
#fill_page(page) ⇒ Object
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
14 15 16 17 18 19 |
# 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 |