| 1 | package Reaction::UI::ViewPort::Collection::Role::Pager; | ||
| 2 | |||
| 3 | 5 | ▶ | use Reaction::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 5 | ▶ | use aliased 'Reaction::InterfaceModel::Collection'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | # XX This needs to be consumed after Ordered | ||
| 8 | 5 | ▶ | use namespace::clean -except => [ qw(meta) ]; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 5 | ▶ | use MooseX::Types::Moose qw/Int/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | #has paged_collection => (isa => Collection, is => 'rw', lazy_build => 1); | ||
| 12 | |||
| 13 | 5 | has pager => (isa => 'Data::Page', is => 'rw', lazy_build => 1); | |
| 14 | 5 | has page => (isa => Int, is => 'rw', lazy_build => 1, trigger_adopt('page'), clearer => 'clear_page'); | |
| 15 | 5 | has per_page => (isa => Int, is => 'rw', lazy_build => 1, trigger_adopt('page')); | |
| 16 | 5 | has per_page_max => (isa => Int, is => 'rw', lazy_build => 1); | |
| 17 | 0 | ▶ | sub _build_page { 1 }; |
|
Subroutine
_build_page: not called CC=1 SCAR=6.9
| |||
| 18 | 0 | ▶ | sub _build_per_page { 10 }; |
|
Subroutine
_build_per_page: not called CC=1 SCAR=6.9
| |||
| 19 | 0 | ▶ | sub _build_per_page_max { 100 }; |
|
Subroutine
_build_per_page_max: not called CC=1 SCAR=6.9
| |||
| 20 | 0 | ▶ | sub _build_pager { shift->current_collection->pager }; |
|
Subroutine
_build_pager: not called CC=1 SCAR=6.9
| |||
| 21 | 0 | ▶ | sub adopt_page { |
|
Subroutine
adopt_page: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 22 | 0 | my ($self) = @_; | |
| 23 | #$self->clear_paged_collection; | ||
| 24 | |||
| 25 | 0 | $self->clear_pager; | |
| 26 | 0 | $self->clear_current_collection; | |
| 27 | }; | ||
| 28 | |||
| 29 | 0 | ▶ | after clear_page => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 30 | 0 | my ($self) = @_; | |
| 31 | 0 | $self->clear_pager; | |
| 32 | 0 | $self->clear_current_collection; | |
| 33 | 5 | }; | |
| 34 | |||
| 35 | 0 | ▶ | around accept_events => sub { ('page','per_page', shift->(@_)); }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 36 | |||
| 37 | #implements build_paged_collection => as { | ||
| 38 | # my ($self) = @_; | ||
| 39 | # my $collection = $self->current_collection; | ||
| 40 | # return $collection->where(undef, {rows => $self->per_page})->page($self->page); | ||
| 41 | #}; | ||
| 42 | |||
| 43 | 0 | ▶ | around _build_current_collection => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 44 | 0 | my $orig = shift; | |
| 45 | 0 | my ($self) = @_; | |
| 46 | 0 | my $collection = $orig->(@_); | |
| 47 | 0 | return $collection->where(undef, {rows => $self->per_page})->page($self->page); | |
| 48 | 5 | }; | |
| 49 | |||
| 50 | 5 | 1; | |
| 51 | |||
| 52 | __END__; | ||