Finder/DB.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 100% 55 / 55 CC 3 SCAR 4.1
CC
3
Cov
100%
find
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
↑ Summary Finder/DB/Schema/Result/Data.pm »
1 package Data::Context::Finder::DB;
2  
3 # Created on: 2016-01-19 09:13:05
4 # Create by: Ivan Wills
5 # $Id$
6 # $Revision$, $HeadURL$, $Date$
7 # $Revision$, $Source$, $Date$
8  
9 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use List::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 #use List::MoreUtils;
16 2 ▶use Data::Dumper qw/Dumper/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use English qw/ -no_match_vars /;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Data::Context::Loader::DB;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 extends 'Data::Context::Finder';
21  
22 2 our $VERSION = version->new('0.0.1');
23  
24 2 has schema => (
25 is => 'rw',
26 isa => 'DBIx::Class::Schema',
27 );
28 2 has table => (
29 is => 'rw',
30 isa => 'Str',
31 default => 'Data',
32 );
33 2 has default => (
34 is => 'rw',
35 isa => 'Str',
36 default => '_default',
37 );
38  
39 10 ▶sub find {
Subroutine find: called CC=3 SCAR=11.0
Pod documented
40 10 my ($self, @path) = @_;
41  
42 10 my $row = $self->schema->resultset($self->table)->find(join '/', @path);
43  
44 10 ▶ if ($row) {
Branch: 2 branches
BranchTrueFalseTotal
if ($row) { } 3 7 10
elsif ($row = $self->schema->resultset($self->table)->find(join('/', @path[0 .. @path - 2], $self->default))) { } 2 5 7
45 3 return Data::Context::Loader::DB->new(
46 raw => $row->json,
47 );
48 }
49 elsif ($row = $self->schema->resultset($self->table)->find(join '/', @path[0 .. @path - 2], $self->default)) {
50 2 return Data::Context::Loader::DB->new(
51 raw => $row->json,
52 );
53 }
54  
55 5 return;
56 }
57  
58 2 __PACKAGE__->meta->make_immutable;
59  
60 2 1;
61  
62 __END__
↑ Summary Finder/DB/Schema/Result/Data.pm »