line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Google::Analytics::Row; |
2
|
|
|
|
|
|
|
$Net::Google::Analytics::Row::VERSION = '3.03'; |
3
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
60
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Base class for Google Analytics API result rows |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
2
|
|
|
2
|
|
935
|
require Class::XSAccessor::Array; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $class_count = 0; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Dynamically generate a class with accessors |
15
|
|
|
|
|
|
|
sub _gen_class { |
16
|
3
|
|
|
3
|
|
7
|
my (undef, $column_headers) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Generate unique package name |
19
|
3
|
|
|
|
|
8
|
my $class = "Net::Google::Analytics::Row_$class_count"; |
20
|
3
|
|
|
|
|
5
|
++$class_count; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
# Set globals of new class |
24
|
2
|
|
|
2
|
|
1595
|
no strict 'refs'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
286
|
|
|
3
|
|
|
|
|
4
|
|
25
|
3
|
|
|
|
|
6
|
@{ "${class}::ISA" } = qw(Net::Google::Analytics::Row); |
|
3
|
|
|
|
|
58
|
|
26
|
3
|
|
|
|
|
5
|
${ "${class}::column_headers" } = $column_headers; |
|
3
|
|
|
|
|
17
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Create accessors |
30
|
3
|
|
|
|
|
4
|
my %getters; |
31
|
3
|
|
|
|
|
14
|
for (my $i = 0; $i < @$column_headers; ++$i) { |
32
|
9
|
|
|
|
|
17
|
my $getter = 'get_' . $column_headers->[$i]->{name}; |
33
|
9
|
|
|
|
|
23
|
$getters{$getter} = $i; |
34
|
|
|
|
|
|
|
} |
35
|
3
|
|
|
|
|
26
|
Class::XSAccessor::Array->import( |
36
|
|
|
|
|
|
|
class => $class, |
37
|
|
|
|
|
|
|
getters => \%getters, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
3
|
|
|
|
|
615
|
return $class; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
12
|
|
|
12
|
1
|
15
|
my ($class, $row) = @_; |
45
|
12
|
|
|
|
|
44
|
return bless($row, $class); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _column_headers { |
49
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
50
|
1
|
|
|
|
|
3
|
my $class = ref($self); |
51
|
2
|
|
|
2
|
|
8
|
no strict 'refs'; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
190
|
|
52
|
1
|
|
|
|
|
2
|
return ${ "${class}::column_headers" }; |
|
1
|
|
|
|
|
9
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get { |
56
|
1
|
|
|
1
|
1
|
3229
|
my ($self, $name) = @_; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
11
|
my $column_headers = $self->_column_headers; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
6
|
for (my $i = 0; $i < @$column_headers; ++$i) { |
61
|
4
|
100
|
|
|
|
28
|
return $self->[$i] if $column_headers->[$i]->{name} eq $name; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return undef; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |