RuleEngine/Data.pm

filter: Statementstmt 69.0% 29 / 42 Branchbran 16.6% 1 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 10 / 15 Podpod 100% 10 / 10 totaltotal 68.4% 50 / 73 CC 5 SCAR 12.6
CC
5
Cov
62%
clear
12.0
delete
6.0
set
2.0
CRAP 3.5
« RuleEngine/Output.pm ↑ Summary RuleEngine/Rule/InputMatchesRegexp.pm »
1 package VS::RuleEngine::Data;
2  
3 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 33 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 33 ▶use Scalar::Util qw(refaddr);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 33 my %Locked;
10  
11 0 ▶sub lock {
Subroutine lock: not called CC=1 SCAR=6.9
Pod documented
12 0 my $self = shift;
13 0 $Locked{refaddr $self} = 1;
14 }
15  
16 0 ▶sub unlock {
Subroutine unlock: not called CC=1 SCAR=6.9
Pod documented
17 0 my $self = shift;
18 0 delete $Locked{refaddr $self};
19 }
20  
21 462 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
22 462 my $pkg = shift;
23 462 my $self = bless { @_ }, $pkg;
24 462 return $self;
25 }
26  
27 315 ▶sub set {
Subroutine set: called CC=2 SCAR=7.1
Pod documented
28 315 my ($self, $key, $value) = @_;
29 315 ▶ croak "Can't modify locked object" if $Locked{refaddr $self};
Branch: 1 branch
BranchTrueFalseTotal
if $Locked{builtin::refaddr($self)} 0 315 315
30 315 $self->{$key} = $value;
31 }
32  
33 33 *put = \&set;
34  
35 0 ▶sub delete {
Subroutine delete: not called CC=2 SCAR=17.9
Pod documented
36 0 my ($self, $key) = @_;
37 0 ▶ croak "Can't modify locked object" if $Locked{refaddr $self};
Branch: 1 branch
BranchTrueFalseTotal
if $Locked{builtin::refaddr($self)} 0 0 0
38 0 CORE::delete $self->{$key};
39 }
40  
41 0 ▶sub clear {
Subroutine clear: not called CC=3 SCAR=24.8
Pod documented
42 0 my $self = shift;
43 0 ▶ croak "Can't modify locked object" if $Locked{refaddr $self};
Branch: 1 branch
BranchTrueFalseTotal
if $Locked{builtin::refaddr($self)} 0 0 0
44 0 delete $self->{$_} for keys %{$self};
45 }
46  
47 321 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod documented
48 321 my ($self, $key) = @_;
49 321 return $self->{$key};
50 }
51  
52 107 ▶sub keys {
Subroutine keys: called CC=1 SCAR=0.0
Pod documented
53 107 my $self = shift;
54 107 return CORE::keys %$self;
55 }
56  
57 0 ▶sub values {
Subroutine values: not called CC=1 SCAR=6.9
Pod documented
58 0 my $self = shift;
59 0 return CORE::values %$self;
60 }
61  
62 740 ▶sub exists {
Subroutine exists: called CC=1 SCAR=0.0
Pod documented
63 740 my ($self, $key) = @_;
64 740 return CORE::exists $self->{$key};
65 }
66  
67 462 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
68 462 my $self = shift;
69 462 delete $Locked{refaddr $self};
70 }
71  
72 33 1;
73 __END__
« RuleEngine/Output.pm ↑ Summary RuleEngine/Rule/InputMatchesRegexp.pm »