Mojito/Role/DB/Deep.pm

filter: Statementstmt 74.1% 23 / 31 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 5 / 10 Podpod n/a totaltotal 62.2% 28 / 45 CC 3 SCAR 10.7
CC
3
Cov
66%
__ANON__
6.0
_build_db
6.0
__ANON__
2.0
CRAP 2.9
« Mojito/Role/DB/Mongo.pm ↑ Summary Mojito/Page/Publish.pm »
1 5 ▶use strictures 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Mojito::Role::DB::Deep;
3 5 $Mojito::Role::DB::Deep::VERSION = '0.25';
4 5 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Mojito::Model::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use DBM::Deep;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Data::Dumper::Concise;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 with('Mojito::Role::DB::OID');
10  
11 has 'db_name' => (
12 is => 'rw',
13 lazy => 1,
14 # Set a test DB when RELEASE_TESTING
15 0 ▶ default => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
16 $ENV{RELEASE_TESTING}
17 ? '/home/hunter/mojito_test.db'
18 0 ▶ : Mojito::Model::Config->new->config->{dbm_deep_filepath};
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'RELEASE_TESTING'} ? : 0 0 0
19 },
20 5 clearer => 'clear_db_name',
21 );
22 5 has 'db' => (
23 is => 'rw',
24 lazy => 1,
25 builder => '_build_db',
26 clearer => 'clear_db',
27 );
28 5 has 'collection' => (
29 is => 'ro',
30 lazy => 1,
31 builder => '_build_collection',
32 clearer => 'clear_collection',
33 );
34 has 'collection_name' => (
35 is => 'rw',
36 lazy => 1,
37 0 ▶ default => sub { 'notes' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 5 clearer => 'clear_collection_name',
39 );
40 has 'db_host' => (
41 is => 'ro',
42 lazy => 1,
43 0 ▶ default => sub { 'localhost:27017' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 5 );
45  
46 0 ▶sub _build_db {
Subroutine _build_db: not called CC=2 SCAR=17.9
47 0 ▶ warn "BUILD DEEP DB CONNECTION for ", $_[0]->db_name if $ENV{MOJITO_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"MOJITO_DEBUG"} 0 0 0
48 # use Devel::StackTrace;
49 # my $trace = Devel::StackTrace->new;
50 # warn $trace->as_string;
51 0 return DBM::Deep->new($_[0]->db_name);
52 }
53 0 ▶sub _build_collection {
Subroutine _build_collection: not called CC=1 SCAR=6.9
54 0 my $self = shift;
55 0 my $collection_name = $self->collection_name;
56 0 $self->db->{$collection_name};
57 }
58  
59  
60 5 1;
« Mojito/Role/DB/Mongo.pm ↑ Summary Mojito/Page/Publish.pm »