YADV.pm

filter: Statementstmt 87.5% 7 / 8 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 90.9% 10 / 11 CC 1 SCAR 0.4
CC
1
Cov
88%
BEGIN
1.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« YADV/Structure/Scalar.pm ↑ Summary
1 package Data::YADV;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 0 ▶use v5.008_001;
Subroutine BEGIN: called CC=1 SCAR=1.2
6  
7 our $VERSION = '0.001';
8  
9 use Data::YADV::Structure;
10 use String::CamelCase 'camelize';
11  
12 sub new {
13 my ($class, $structure, %args) = @_;
14  
15 $args{error_handler} ||= \&_error_handler;
16  
17 bless {%args, structure => Data::YADV::Structure->new($structure)},
18 $class;
19 }
20  
21 sub check {
22 my ($self, $schema, @path) = @_;
23
24 my $module = $self->schema_to_module($schema);
25 my $child = $self->{structure}->get_child(@path);
26 $self->build_checker($module, $child)->verify();
27 }
28  
29 sub schema_to_module {
30 my ($self, $schema) = @_;
31  
32 'Schema::' . camelize($schema);
33 }
34  
35 sub build_checker {
36 my ($self, $module, @args) = @_;
37  
38 $module->new(
39 @args,
40 schema => $self,
41 error_cb => $self->{error_handler}
42 );
43 }
44  
45 sub _error_handler {
46 my ($path, $message) = @_;
47 warn "$path: $message\n";
48 }
49  
50 1;
51 __END__
« YADV/Structure/Scalar.pm ↑ Summary