Subject: | a means to initialize to last page |
In some search results, it is good to start with the last items (i.e., to show the user the most recent additions to a database). It would be really convenient to be able to do this from the outset, at object creation, via something that might look like this:
$page = Data::Page->new($total, $increment, 'LAST');
Instead, to do this you have to either pass in a huge integer as the page number, or do something like this, immediately after creating the object:
if ($requested_page_num eq 'last') {
$page->{CURRENT_PAGE} = $page->last_page;
}
It would be nice if there was a more elegant, non-kludgy means to do this. Maybe just a CURRENT_PAGE mutator:
$page->set_page($page->last_page);
It's basically equivalent to setting $page->{CURRENT_PAGE}, but wouldn't require hacking through the code (and into the object structure) to figure out how to do it. A set_page() would have the added advantage of being able to test the incoming value and raise a warning if a non-numeric value was passed in.