DWH_File/Tie/Subscripted.pm

filter: Statementstmt 95.6% 44 / 46 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 0.0% 0 / 3 totaltotal 90.0% 63 / 70 CC 5 SCAR 4.4
CC
5
Cov
94%
EXISTS
2.3
STORE
2.0
FETCH
2.0
CRAP 1.6
« DWH_File/Cached.pm ↑ Summary DWH_File/Reference.pm »
1 package DWH_File::Tie::Subscripted;
2  
3 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use vars qw( @ISA $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 ▶use DWH_File::Subscript;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use DWH_File::Value::Factory;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use DWH_File::Tie;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 @ISA = qw( DWH_File::Tie );
12 9 $VERSION = 0.01;
13  
14 132 ▶sub STORE {
Subroutine STORE: called CC=2 SCAR=6.9
15 132 my ( $self, $key, $value_in ) = @_;
16 132 my $subscript = $self->get_subscript( $key );
17 my $value = DWH_File::Value::Factory->from_input( $self->{ kernel },
18 132 $value_in );
19 132 my $node = $self->get_node( $subscript );
20 132 ▶ unless ( $node ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($node) 130 2 132
21 130 $node = $self->node_class->new;
22 130 $self->handle_new_node( $node, $subscript, $value );
23 }
24 132 $node->set_value( $value );
25 # make lazy
26 132 $self->{ kernel }->store( $subscript, $node );
27 }
28  
29 505 ▶sub FETCH {
Subroutine FETCH: called CC=2 SCAR=6.9
30 505 my $subscript = $_[ 0 ]->get_subscript( $_[ 1 ] );
31 505 ▶ my $node = $_[ 0 ]->get_node( $subscript ) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $node = $_[0]->get_node($subscript) or return undef 503 2 505
32 503 return $node->{ value }->actual_value;
33 }
34  
35 3 ▶sub EXISTS {
Subroutine EXISTS: called CC=2 SCAR=8.1
36 3 my $subscript = $_[ 0 ]->get_subscript( $_[ 1 ] );
37 3 ▶ my $node = $_[ 0 ]->get_node( $subscript ) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $node = $_[0]->get_node($subscript) or return 0 0 3 3
38 0 return 1;
39 }
40  
41 229 ▶sub get_subscript {
Subroutine get_subscript: called CC=1 SCAR=0.0
Pod undocumented
42 229 return DWH_File::Subscript->from_input( @_[ 0, 1 ] );
43 }
44  
45 810 ▶sub get_node {
Subroutine get_node: called CC=2 SCAR=6.9
Pod undocumented
46 810 my ( $self, $subscript ) = @_;
47 810 my $data = $self->{ kernel }->fetch( $subscript );
48 810 ▶ if ( $data ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data) { } 675 135 810
49 return $self->node_class->from_stored( $self->{ kernel },
50 675 $data, $subscript );
51 }
52 135 else { return undef }
53 }
54  
55 0 ▶sub CLEAR { die "Abstract method called" }
Subroutine CLEAR: not called CC=1 SCAR=6.9
56  
57 2 ▶sub vanish {
Subroutine vanish: called CC=1 SCAR=0.0
Pod undocumented
58 2 my ( $self ) = @_;
59 2 $self->CLEAR;
60 2 $self->{ kernel }->unground( $self );
61 }
62  
63 9 1;
64  
65 __END__
« DWH_File/Cached.pm ↑ Summary DWH_File/Reference.pm »