| 1 | package Dancer::Plugin::PageHistory::Page; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Dancer::Plugin::PageHistory::Page - Page object for Dancer::Plugin::PageHistory | ||
| 6 | |||
| 7 | =cut | ||
| 8 | |||
| 9 | 4 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 4 | ▶ | use Types::Standard qw(Str HashRef); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 4 | ▶ | use URI; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 4 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | =head1 ATTRIBUTES | ||
| 15 | |||
| 16 | =head2 attributes | ||
| 17 | |||
| 18 | Extra attributes as a hash reference, e.g.: SKU for a product page. | ||
| 19 | |||
| 20 | =cut | ||
| 21 | |||
| 22 | 4 | has attributes => ( | |
| 23 | is => 'ro', | ||
| 24 | isa => HashRef, | ||
| 25 | predicate => 1, | ||
| 26 | ); | ||
| 27 | |||
| 28 | =head2 path | ||
| 29 | |||
| 30 | Absolute path of the page. This is the only required attribute. | ||
| 31 | |||
| 32 | =cut | ||
| 33 | |||
| 34 | 4 | has path => ( | |
| 35 | is => 'ro', | ||
| 36 | isa => Str, | ||
| 37 | required => 1, | ||
| 38 | ); | ||
| 39 | |||
| 40 | =head2 query | ||
| 41 | |||
| 42 | Query parameters as a hash reference. | ||
| 43 | |||
| 44 | =cut | ||
| 45 | |||
| 46 | 4 | has query => ( | |
| 47 | is => 'ro', | ||
| 48 | isa => HashRef, | ||
| 49 | ); | ||
| 50 | |||
| 51 | =head2 title | ||
| 52 | |||
| 53 | Page title. | ||
| 54 | |||
| 55 | =cut | ||
| 56 | |||
| 57 | 4 | has title => ( | |
| 58 | is => 'ro', | ||
| 59 | isa => Str, | ||
| 60 | predicate => 1, | ||
| 61 | ); | ||
| 62 | |||
| 63 | =head1 METHODS | ||
| 64 | |||
| 65 | =head2 predicates | ||
| 66 | |||
| 67 | The following predicate methods are defined: | ||
| 68 | |||
| 69 | =over | ||
| 70 | |||
| 71 | =item * has_attributes | ||
| 72 | |||
| 73 | =item * has_title | ||
| 74 | |||
| 75 | =back | ||
| 76 | |||
| 77 | =head2 uri | ||
| 78 | |||
| 79 | Returns the string URI for L</path> and L</query>. | ||
| 80 | |||
| 81 | =cut | ||
| 82 | |||
| 83 | 38 | ▶ | sub uri { |
|
Subroutine
uri: called CC=1 SCAR=0.0
Pod
documented
| |||
| 84 | 38 | my $self = shift; | |
| 85 | 38 | my $uri = URI->new( $self->path ); | |
| 86 | 38 | $uri->query_form($self->query); | |
| 87 | 38 | return $uri->as_string; | |
| 88 | } | ||
| 89 | |||
| 90 | 4 | 1; | |