line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
113
|
|
8
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
181
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
20
|
use Carp; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1572
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new |
13
|
|
|
|
|
|
|
{ |
14
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
return bless {}, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub get_result |
20
|
|
|
|
|
|
|
{ |
21
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
22
|
0
|
|
|
|
|
|
my ( $name ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
carp "No result '$name'" unless exists $self->{$name}; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
return $self->{$name}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub push_result |
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
32
|
0
|
|
|
|
|
|
my ( $name, $value ) = @_; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if( !exists $self->{$name} ) { |
|
|
0
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$self->{$name} = [ $value ]; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif( ref $self->{$name} eq "ARRAY" ) { |
38
|
0
|
|
|
|
|
|
push @{ $self->{$name} }, $value; |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
0
|
|
|
|
|
|
croak "Expected '$name' to be an ARRAY result"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub merge_from |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
my ( $other ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
foreach my $name ( %$other ) { |
51
|
0
|
|
|
|
|
|
my $otherval = $other->{$name}; |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if( !$self->{$name} ) { |
54
|
0
|
|
|
|
|
|
$self->{$name} = $otherval; |
55
|
0
|
|
|
|
|
|
next; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $myval = $self->{$name}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Already had it - type matches? |
61
|
0
|
0
|
|
|
|
|
if( ref $myval ne ref $otherval ) { |
62
|
0
|
|
|
|
|
|
croak "Cannot merge; '$name' has different result types"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $type = ref $myval; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if( ref $myval eq "ARRAY" ) { |
68
|
0
|
|
|
|
|
|
push @$myval, @$otherval; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
0
|
|
|
|
|
|
croak "Don't know how to handle result type '$name' ($type)"; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
0x55AA; |