File Coverage

blib/lib/App/DBCritic/Policy.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 33 33 100.0


line stmt bran cond sub pod time code
1             package App::DBCritic::Policy;
2              
3 5     5   2563 use strict;
  5         8  
  5         148  
4 5     5   19 use utf8;
  5         6  
  5         22  
5 5     5   165 use Modern::Perl '2011'; ## no critic (Modules::ProhibitUseQuotedVersion)
  5         7  
  5         26  
6              
7             our $VERSION = '0.021'; # TRIAL VERSION
8 5     5   588 use English '-no_match_vars';
  5         7  
  5         41  
9 5     5   1925 use Moo::Role;
  5         19  
  5         31  
10 5     5   3905 use App::DBCritic::Violation;
  5         15  
  5         269  
11 5     5   30 use namespace::autoclean -also => qr{\A _}xms;
  5         18  
  5         57  
12              
13             requires qw(description explanation violates);
14              
15             around violates => sub {
16             my ( $orig, $self ) = splice @ARG, 0, 2;
17             $self->_set_element(shift);
18             $self->_set_schema(shift);
19              
20             my $details = $self->$orig(@ARG);
21             return $self->violation($details) if $details;
22              
23             return;
24             };
25              
26             has element => ( is => 'ro', init_arg => undef, writer => '_set_element' );
27              
28             sub violation {
29 4     4 1 7 my $self = shift;
30 12         73 return App::DBCritic::Violation->new(
31             details => shift,
32 4         13 map { $ARG => $self->$ARG } qw(description explanation element),
33             );
34             }
35              
36             has schema => ( is => 'ro', writer => '_set_schema' );
37              
38             1;
39              
40             # ABSTRACT: Role for criticizing database schemas
41              
42             __END__