Circle/Rule/Resultset.pm

filter: Statementstmt 28.9% 11 / 38 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 4 totaltotal 22.9% 14 / 61 CC 8 SCAR 26.7
CC
8
Cov
22%
merge_from
30.0
push_result
12.0
get_result
6.0
CRAP 14.5
« Circle/Net/IRC/Target.pm ↑ Summary Circle/Rule/Store.pm »
1 # You may distribute under the terms of the GNU General Public License
2 #
3 # (C) Paul Evans, 2008-2010 -- leonerd@leonerd.org.uk
4  
5 package Circle::Rule::Resultset;
6  
7 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our $VERSION = '0.173320';
11  
12 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new
15 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
16 0 my $class = shift;
17  
18 0 return bless {}, $class;
19 }
20  
21 sub get_result
22 0 ▶{
Subroutine get_result: not called CC=2 SCAR=17.9
Pod undocumented
23 0 my $self = shift;
24 0 my ( $name ) = @_;
25  
26 0 ▶ carp "No result '$name'" unless exists $self->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$name} 0 0 0
27  
28 0 return $self->{$name};
29 }
30  
31 sub push_result
32 0 ▶{
Subroutine push_result: not called CC=3 SCAR=24.8
Pod undocumented
33 0 my $self = shift;
34 0 my ( $name, $value ) = @_;
35  
36 0 ▶ if( !exists $self->{$name} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $self->{$name}) { } 0 0 0
elsif (ref $self->{$name} eq 'ARRAY') { } 0 0 0
37 0 $self->{$name} = [ $value ];
38 }
39 elsif( ref $self->{$name} eq "ARRAY" ) {
40 0 push @{ $self->{$name} }, $value;
41 }
42 else {
43 0 croak "Expected '$name' to be an ARRAY result";
44 }
45 }
46  
47 sub merge_from
48 0 ▶{
Subroutine merge_from: not called CC=5 SCAR=34.0
Pod undocumented
49 0 my $self = shift;
50 0 my ( $other ) = @_;
51  
52 0 foreach my $name ( %$other ) {
53 0 my $otherval = $other->{$name};
54  
55 0 ▶ if( !$self->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{$name}) 0 0 0
56 0 $self->{$name} = $otherval;
57 0 next;
58 }
59  
60 0 my $myval = $self->{$name};
61  
62 # Already had it - type matches?
63 0 ▶ if( ref $myval ne ref $otherval ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $myval ne ref $otherval) 0 0 0
64 0 croak "Cannot merge; '$name' has different result types";
65 }
66  
67 0 my $type = ref $myval;
68  
69 0 ▶ if( ref $myval eq "ARRAY" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $myval eq 'ARRAY') { } 0 0 0
70 0 push @$myval, @$otherval;
71 }
72 else {
73 0 croak "Don't know how to handle result type '$name' ($type)";
74 }
75 }
76 }
77  
78 4 0x55AA;
« Circle/Net/IRC/Target.pm ↑ Summary Circle/Rule/Store.pm »