Method: Webby::Paginator#initialize
- Defined in:
- lib/webby/stelan/paginator.rb
#initialize(count, per_page, resource, &select) ⇒ Paginator
Instantiate a new Paginator object
Provide:
-
A total count of the number of objects to paginate
-
The number of objects in each page
-
A block that returns the array of items
-
The block is passed the item offset (and the number of items to show per page, for convenience, if the arity is 2)
-
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/webby/stelan/paginator.rb', line 32 def initialize(count, per_page, resource, &select) @count, @per_page, @resource = count, per_page, resource @meta_data = @resource..dup @filename = @resource.filename @directory = @resource.directory unless select raise MissingSelectError, "Must provide block to select data for each page" end @select = select end |