| 1 | package Catalyst::Controller::DBIC::API::StoredResultSource; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 16 | $Catalyst::Controller::DBIC::API::StoredResultSource::VERSION = '2.009000'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | #ABSTRACT: Provides accessors for static resources | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use MooseX::Types::Moose(':all'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 16 | ▶ | use Catalyst::Controller::DBIC::API::Types(':all'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 16 | requires '_application'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 16 | has 'class' => ( is => 'ro', isa => Str, writer => '_set_class' ); | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 16 | has 'result_class' => ( | |||||||||||||||||||||||||||||||||||||||||
| 18 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | isa => Maybe [Str], | ||||||||||||||||||||||||||||||||||||||||||
| 20 | default => 'DBIx::Class::ResultClass::HashRefInflator' | ||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 693 | ▶ | sub stored_result_source { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stored_result_source: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 693 | return shift->stored_model->result_source; | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 693 | ▶ | sub stored_model { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stored_model: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 693 | return $_[0]->_application->model( $_[0]->class ); | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 571 | ▶ | sub check_has_column { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_has_column: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 571 | my ( $self, $col ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 571 | ▶ | die "Column '$col' does not exist in ResultSet '${\$self->class}'" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | unless $self->stored_result_source->has_column($col); | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 77 | ▶ | sub check_has_relation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_has_relation: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 77 | my ( $self, $rel, $other, $nest, $static ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 77 | ▶ | $nest ||= $self->stored_result_source; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$nest ||= $self->stored_result_source
MC/DC0%0/2
$nest ||= $self->stored_result_source
$nest
$self->stored_result_source
Truth table66%2/3
A ||= B
A= $nestB= $self->stored_result_source
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 77 | ▶ | if ( HashRef->check($other) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 20 | my $rel_src = $nest->related_source($rel); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 13 | ▶ | die "Relation '$rel_src' does not exist" if not defined($rel_src); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 13 | ▶ | while ( my ( $k, $v ) = each %$other ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 13 | $self->check_has_relation( $k, $v, $rel_src, $static ); | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 57 | ▶ | return 1 if $static && ArrayRef->check($other) && $other->[0] eq '*'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$static and ArrayRef()->check($other) and $other->[0] eq "*"
$static and ArrayRef()->check($other)
MC/DC66%2/3
$static and ArrayRef()->check($other) and $other->[0] eq "*"
$static
ArrayRef()->check($other)
$other->[0] eq "*"
Truth table75%3/4
A and B and C
A= $staticB= ArrayRef()->check($other)C= $other->[0] eq "*"
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 27 | ▶ | die "Relation '$rel' does not exist in ${\$nest->from}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$nest->has_relationship($rel) or $nest->has_column($rel)
MC/DC100%2/2
$nest->has_relationship($rel) or $nest->has_column($rel)
$nest->has_relationship($rel)
$nest->has_column($rel)
Truth table100%3/3
A or B
A= $nest->has_relationship($rel)B= $nest->has_column($rel)
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | unless $nest->has_relationship($rel) || $nest->has_column($rel); | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 19 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 632 | ▶ | sub check_column_relation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_column_relation: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 632 | my ( $self, $col_rel, $static ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 632 | ▶ | if ( HashRef->check($col_rel) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 61 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 61 | ▶ | while ( my ( $k, $v ) = each %$col_rel ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 61 | $self->check_has_relation( $k, $v, undef, $static ); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 15 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | # not a relation but a column with a predicate | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 15 | ▶ | while ( my ( $k, undef ) = each %$col_rel ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->check_has_column($k); | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 61 | } | |||||||||||||||||||||||||||||||||||||||||
| 79 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 571 | $self->check_has_column($col_rel); | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||||||||||||||||||||||||||