File Coverage

blib/lib/App/DBCritic/Violation.pm
Criterion Covered Total %
statement 32 32 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod n/a
total 42 42 100.0


line stmt bran cond sub pod time code
1             package App::DBCritic::Violation;
2              
3 5     5   23 use strict;
  5         52  
  5         177  
4 5     5   19 use utf8;
  5         6  
  5         24  
5 5     5   99 use Modern::Perl '2011'; ## no critic (Modules::ProhibitUseQuotedVersion)
  5         8  
  5         21  
6              
7             our $VERSION = '0.021'; # TRIAL VERSION
8 5     5   3291 use Const::Fast;
  5         4189  
  5         26  
9 5     5   340 use English '-no_match_vars';
  5         8  
  5         27  
10 5     5   1460 use Moo;
  5         7  
  5         33  
11 5     5   1551 use Sub::Quote;
  5         10  
  5         370  
12 5     5   25 use overload q{""} => sub { shift->as_string };
  5     4   5  
  5         49  
  4         19  
13              
14             const my @TEXT_FIELDS => qw(description explanation details);
15             for (@TEXT_FIELDS) {
16             has $_ => ( is => 'ro', default => quote_sub q{q{}} );
17             }
18              
19             has element => ( is => 'ro' );
20             has as_string => ( is => 'ro', lazy => 1, default => \&_build_as_string );
21              
22             sub _build_as_string {
23 4     4   1672 my $self = shift;
24 4         18 my $element = $self->element;
25 4         9 my $type = ref $element;
26              
27 4         24 $type =~ s/\A .* :://xms;
28 4         79 const my %TYPE_MAP => (
29             Table => $element->from,
30             ResultSet => $element->result_class,
31             Schema => 'schema',
32             );
33 12         68 return "[$type $TYPE_MAP{$type}] " . join "\n",
34 4         577 map { $self->$ARG } @TEXT_FIELDS;
35             }
36              
37             1;
38              
39             # ABSTRACT: A violation of a App::DBCritic::Policy
40              
41             __END__