API/StaticArguments.pm

filter: Statementstmt 96.2% 51 / 53 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 8 / 10 Podpod n/a totaltotal 94.2% 65 / 69 CC 7 SCAR 9.2
CC
7
Cov
97%
_check_rel
5.0
__ANON__
2.0
_build_prefetch_validator
2.0
CRAP 2.5
« API/Validator/Visitor.pm ↑ Summary API/JoinBuilder.pm »
1 package Catalyst::Controller::DBIC::API::StaticArguments;
2 16 $Catalyst::Controller::DBIC::API::StaticArguments::VERSION = '2.009000';
3 #ABSTRACT: Provides controller level configuration arguments
4 16 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use MooseX::Types::Moose(':all');
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 requires 'check_column_relation';
9  
10  
11 16 foreach my $var (
12 qw( create_requires create_allows update_requires update_allows ))
13 {
14 has $var => (
15 is => 'ro',
16 isa => ArrayRef [ Str | HashRef ],
17 traits => ['Array'],
18 423 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
19 361 ▶ trigger => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
20 361 my ( $self, $new ) = @_;
21 361 $self->check_column_relation( $_, 1 ) for @$new;
22 },
23 64 handles => {
24 "get_${var}_column" => 'get',
25 "set_${var}_column" => 'set',
26 "delete_${var}_column" => 'delete',
27 "insert_${var}_column" => 'insert',
28 "count_${var}_column" => 'count',
29 "all_${var}_columns" => 'elements',
30 }
31 );
32  
33 before "set_${var}_column" =>
34 0 ▶ sub { $_[0]->check_column_relation( $_[2], 1 ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
35 before "insert_${var}_column" =>
36 0 ▶ sub { $_[0]->check_column_relation( $_[2], 1 ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
37 }
38  
39  
40 has 'prefetch_allows' => (
41 is => 'ro',
42 writer => '_set_prefetch_allows',
43 isa => ArrayRef [ ArrayRef | Str | HashRef ],
44 121 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
45 16 predicate => 'has_prefetch_allows',
46 traits => ['Array'],
47 handles => { all_prefetch_allows => 'elements', },
48 );
49  
50 16 has 'prefetch_validator' => (
51 is => 'ro',
52 isa => 'Catalyst::Controller::DBIC::API::Validator',
53 lazy_build => 1,
54 );
55  
56 2 ▶sub _build_prefetch_validator {
Subroutine _build_prefetch_validator: called CC=2 SCAR=6.9
57 2 my $self = shift;
58  
59 5 ▶ sub _check_rel {
Subroutine _check_rel: called CC=5 SCAR=16.1
60 5 my ( $self, $rel, $static, $validator ) = @_;
61 5 ▶ if ( ArrayRef->check($rel) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ArrayRef()->check($rel)) { } 2 3 5
elsif (HashRef()->check($rel)) { } 1 2 3
62 2 foreach my $rel_sub (@$rel) {
63 2 _check_rel( $self, $rel_sub, $static, $validator );
64 }
65 }
66 elsif ( HashRef->check($rel) ) {
67 1 ▶ while ( my ( $k, $v ) = each %$rel ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$rel) 1 1 2
68 1 $self->check_has_relation( $k, $v, undef, $static );
69 }
70 1 $validator->load($rel);
71 }
72 else {
73 2 $self->check_has_relation( $rel, undef, undef, $static );
74 2 $validator->load($rel);
75 }
76 }
77  
78 2 my $validator = Catalyst::Controller::DBIC::API::Validator->new;
79  
80 2 foreach my $rel ( $self->all_prefetch_allows ) {
81 3 _check_rel( $self, $rel, 1, $validator );
82 }
83  
84 2 return $validator;
85 }
86  
87  
88 16 has 'count_arg' => ( is => 'ro', isa => Str, default => 'list_count' );
89  
90  
91 16 has 'page_arg' => ( is => 'ro', isa => Str, default => 'list_page' );
92  
93  
94 16 has 'offset_arg' => ( is => 'ro', isa => Str, default => 'list_offset' );
95  
96  
97 16 has 'select_arg' => ( is => 'ro', isa => Str, default => 'list_returns' );
98  
99  
100 16 has 'as_arg' => ( is => 'ro', isa => Str, default => 'as' );
101  
102  
103 16 has 'search_arg' => ( is => 'ro', isa => Str, default => 'search' );
104  
105  
106 16 has 'grouped_by_arg' =>
107 ( is => 'ro', isa => Str, default => 'list_grouped_by' );
108  
109  
110 16 has 'ordered_by_arg' =>
111 ( is => 'ro', isa => Str, default => 'list_ordered_by' );
112  
113  
114 16 has 'prefetch_arg' => ( is => 'ro', isa => Str, default => 'list_prefetch' );
115  
116  
117 16 has 'stash_key' => ( is => 'ro', isa => Str, default => 'response' );
118  
119  
120 16 has 'data_root' => ( is => 'ro', isa => Str, default => 'list' );
121  
122  
123 16 has 'item_root' => ( is => 'ro', isa => Str, default => 'data' );
124  
125  
126 16 has 'total_entries_arg' =>
127 ( is => 'ro', isa => Str, default => 'totalcount' );
128  
129  
130 16 has 'use_json_boolean' => ( is => 'ro', isa => Bool, default => 0 );
131  
132  
133 16 has 'return_object' => ( is => 'ro', isa => Bool, default => 0 );
134  
135  
136 16 1;
137  
138 __END__
« API/Validator/Visitor.pm ↑ Summary API/JoinBuilder.pm »