lib/Reaction/UI/Controller/Role/GetCollection.pm

filter: Statementstmt 87.5% 14 / 16 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod 100% 1 / 1 totaltotal 77.7% 21 / 27 CC 5 SCAR 16.3
CC
5
Cov
75%
get_collection
5.9
BEGIN
1.0
CRAP 5.1
« lib/Reaction/UI/WidgetClass.pm ↑ Summary lib/Reaction/UI/LayoutSet.pm »
1 package Reaction::UI::Controller::Role::GetCollection;
2  
3 4 ▶use Moose::Role -traits => 'MethodAttributes';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 has model_name => (isa => 'Str', is => 'rw', required => 1);
6 4 has collection_name => (isa => 'Str', is => 'rw', required => 1);
7  
8 3 ▶sub get_collection {
Subroutine get_collection: called CC=5 SCAR=17.8
Pod documented
9 3 my ($self, $c) = @_;
10 3 my $model = $c->model( $self->model_name );
11 3 ▶ confess "Failed to find Catalyst model named: " . $self->model_name
Branch: 1 branch
BranchTrueFalseTotal
unless $model 0 3 3
12 unless $model;
13 3 my $collection = $self->collection_name;
14 3 ▶ if( my $meth = $model->can( $collection ) ){
Branch: 2 branches
BranchTrueFalseTotal
if (my $meth = $model->can($collection)) { } 0 3 3
elsif (my $meta = $model->can('meta')) { } 3 0 3
15 0 return $model->$meth;
16 } elsif ( my $meta = $model->can('meta') ){
17 3 ▶ if ( my $attr = $model->$meta->find_attribute_by_name($collection) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $attr = $model->$meta->find_attribute_by_name($collection)) 3 0 3
18 3 my $reader = $attr->get_read_method;
19 3 return $model->$reader;
20 }
21 }
22 0 confess "Failed to find collection $collection";
23 }
24  
25 4 1;
26  
27 __END__;
« lib/Reaction/UI/WidgetClass.pm ↑ Summary lib/Reaction/UI/LayoutSet.pm »