NAME
Dancer::Plugin::PageHistory::PageSet - collection of pages with accessors
ATTRIBUTES
default_type
For all methods that expect an argument type
then this default_type
will be the one used when type
is not specified. Defaults to default
.
fallback_page
In the event that "latest_page" or "previous_page" have no page to return then "fallback_page" is returned instead.
By default this is set to undef.
You can set this page to something else by passing any of the following as the value of this attribute:
a hash reference to be passed to Dancer::Plugin::PageHistory::Page->new
a Dancer::Plugin::PageHistory::Page object
max_items
The maximum number of each history type
stored in "pages".
pages
A hash reference of arrays of hash references.
Primary key is the history type
such as default
or product
. For each type
an array reference of pages is stored with new pages added at the start of the array reference.
methods
An array reference of extra method names that should be added to the class. For example if one of these method names is 'product' then the following shortcut method will be added:
sub product {
return shift->pages->{"product"};
}
METHODS
add( %args )
$args{type}
defaults to "default_type".
In addition to type
other arguments should be those passed to new
in Dancer::Plugin::PageHistory::Page.
has_pages
Predicate on "pages".
page_index($index, $type)
Returns the page from "pages" of type $type
at position $index
. If $type
is not supplied then "default_type" will be used. If page is not found then "fallback_page" is returned instead.
latest_page($type)
A convenience method equivalent to:
page_index(0, $type)
previous_page
A convenience method equivalent to:
page_index(1, $type)
types
Return all of the page types currently stored in history.
In array context returns an array of type names (keys of "pages") and in scalar context returns the same as an array reference.