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