| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package GeoIP2::Role::Model::Location; |
|
2
|
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
12117
|
use strict; |
|
|
12
|
|
|
|
|
23
|
|
|
|
12
|
|
|
|
|
308
|
|
|
4
|
12
|
|
|
12
|
|
52
|
use warnings; |
|
|
12
|
|
|
|
|
18
|
|
|
|
12
|
|
|
|
|
381
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.006002'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
12
|
|
|
12
|
|
54
|
use Moo::Role; |
|
|
12
|
|
|
|
|
20
|
|
|
|
12
|
|
|
|
|
64
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
12
|
|
|
12
|
|
3648
|
use B; |
|
|
12
|
|
|
|
|
22
|
|
|
|
12
|
|
|
|
|
462
|
|
|
11
|
12
|
|
|
12
|
|
4032
|
use GeoIP2::Record::City; |
|
|
12
|
|
|
|
|
34
|
|
|
|
12
|
|
|
|
|
351
|
|
|
12
|
12
|
|
|
12
|
|
4249
|
use GeoIP2::Record::Continent; |
|
|
12
|
|
|
|
|
33
|
|
|
|
12
|
|
|
|
|
361
|
|
|
13
|
12
|
|
|
12
|
|
4051
|
use GeoIP2::Record::Country; |
|
|
12
|
|
|
|
|
35
|
|
|
|
12
|
|
|
|
|
363
|
|
|
14
|
12
|
|
|
12
|
|
4316
|
use GeoIP2::Record::Location; |
|
|
12
|
|
|
|
|
32
|
|
|
|
12
|
|
|
|
|
350
|
|
|
15
|
12
|
|
|
12
|
|
4029
|
use GeoIP2::Record::MaxMind; |
|
|
12
|
|
|
|
|
31
|
|
|
|
12
|
|
|
|
|
339
|
|
|
16
|
12
|
|
|
12
|
|
3957
|
use GeoIP2::Record::Postal; |
|
|
12
|
|
|
|
|
31
|
|
|
|
12
|
|
|
|
|
315
|
|
|
17
|
12
|
|
|
12
|
|
4138
|
use GeoIP2::Record::RepresentedCountry; |
|
|
12
|
|
|
|
|
34
|
|
|
|
12
|
|
|
|
|
328
|
|
|
18
|
12
|
|
|
12
|
|
4346
|
use GeoIP2::Record::Traits; |
|
|
12
|
|
|
|
|
38
|
|
|
|
12
|
|
|
|
|
540
|
|
|
19
|
12
|
|
|
12
|
|
93
|
use GeoIP2::Types qw( ArrayRef HashRef ); |
|
|
12
|
|
|
|
|
20
|
|
|
|
12
|
|
|
|
|
638
|
|
|
20
|
12
|
|
|
12
|
|
64
|
use Sub::Quote qw( quote_sub ); |
|
|
12
|
|
|
|
|
24
|
|
|
|
12
|
|
|
|
|
401
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
12
|
|
|
12
|
|
66
|
use namespace::clean; |
|
|
12
|
|
|
|
|
32
|
|
|
|
12
|
|
|
|
|
58
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
with 'GeoIP2::Role::Model', 'GeoIP2::Role::HasLocales'; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
## no critic (ProhibitUnusedPrivateSubroutines) |
|
27
|
|
|
|
|
|
|
sub _define_attributes_for_keys { |
|
28
|
35
|
|
|
35
|
|
81
|
my $class = shift; |
|
29
|
35
|
|
|
|
|
102
|
my @keys = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
35
|
|
|
|
|
154
|
my $has = $class->can('_has'); |
|
32
|
|
|
|
|
|
|
|
|
33
|
35
|
|
|
|
|
82
|
for my $key (@keys) { |
|
34
|
275
|
|
|
|
|
248786
|
my $record_class = __PACKAGE__->_record_class_for_key($key); |
|
35
|
|
|
|
|
|
|
|
|
36
|
275
|
|
|
|
|
599
|
my $raw_attr = '_raw_' . $key; |
|
37
|
|
|
|
|
|
|
|
|
38
|
275
|
|
|
|
|
739
|
$has->( |
|
39
|
|
|
|
|
|
|
$raw_attr => ( |
|
40
|
|
|
|
|
|
|
is => 'ro', |
|
41
|
|
|
|
|
|
|
isa => HashRef, |
|
42
|
|
|
|
|
|
|
init_arg => $key, |
|
43
|
|
|
|
|
|
|
default => quote_sub(q{ {} }), |
|
44
|
|
|
|
|
|
|
), |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitCallsToUnexportedSubs) |
|
48
|
|
|
|
|
|
|
$has->( |
|
49
|
|
|
|
|
|
|
$key => ( |
|
50
|
|
|
|
|
|
|
is => 'ro', |
|
51
|
|
|
|
|
|
|
isa => quote_sub( |
|
52
|
|
|
|
|
|
|
sprintf( |
|
53
|
|
|
|
|
|
|
q{ GeoIP2::Types::object_isa_type( $_[0], %s ) }, |
|
54
|
|
|
|
|
|
|
B::perlstring($record_class) |
|
55
|
|
|
|
|
|
|
) |
|
56
|
|
|
|
|
|
|
), |
|
57
|
|
|
|
|
|
|
init_arg => undef, |
|
58
|
|
|
|
|
|
|
lazy => 1, |
|
59
|
|
|
|
|
|
|
default => quote_sub( |
|
60
|
|
|
|
|
|
|
sprintf( |
|
61
|
|
|
|
|
|
|
q{ $_[0]->_build_record( %s, %s ) }, |
|
62
|
275
|
|
|
|
|
75944
|
map { B::perlstring($_) } $key, $raw_attr |
|
|
550
|
|
|
|
|
18357
|
|
|
63
|
|
|
|
|
|
|
) |
|
64
|
|
|
|
|
|
|
), |
|
65
|
|
|
|
|
|
|
), |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
## use critic |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _all_record_names { |
|
72
|
25
|
|
|
25
|
|
155
|
return qw( |
|
73
|
|
|
|
|
|
|
city |
|
74
|
|
|
|
|
|
|
continent |
|
75
|
|
|
|
|
|
|
country |
|
76
|
|
|
|
|
|
|
location |
|
77
|
|
|
|
|
|
|
maxmind |
|
78
|
|
|
|
|
|
|
postal |
|
79
|
|
|
|
|
|
|
registered_country |
|
80
|
|
|
|
|
|
|
represented_country |
|
81
|
|
|
|
|
|
|
traits |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
86
|
|
|
|
|
|
|
my $orig = shift; |
|
87
|
|
|
|
|
|
|
my $self = shift; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $p = $self->$orig(@_); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
delete $p->{raw}; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# We make a copy to avoid a circular reference |
|
94
|
|
|
|
|
|
|
$p->{raw} = { %{$p} }; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
return $p; |
|
97
|
|
|
|
|
|
|
}; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub _build_record { |
|
100
|
81
|
|
|
81
|
|
65032
|
my $self = shift; |
|
101
|
81
|
|
|
|
|
140
|
my $key = shift; |
|
102
|
81
|
|
|
|
|
116
|
my $method = shift; |
|
103
|
|
|
|
|
|
|
|
|
104
|
81
|
|
|
|
|
287
|
my $raw = $self->$method(); |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return $self->_record_class_for_key($key) |
|
107
|
81
|
|
|
|
|
202
|
->new( %{$raw}, locales => $self->locales() ); |
|
|
81
|
|
|
|
|
1196
|
|
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
{ |
|
111
|
|
|
|
|
|
|
my %key_to_class = ( |
|
112
|
|
|
|
|
|
|
maxmind => 'MaxMind', |
|
113
|
|
|
|
|
|
|
registered_country => 'Country', |
|
114
|
|
|
|
|
|
|
represented_country => 'RepresentedCountry', |
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub _record_class_for_key { |
|
118
|
356
|
|
|
356
|
|
614
|
my $self = shift; |
|
119
|
356
|
|
|
|
|
460
|
my $key = shift; |
|
120
|
|
|
|
|
|
|
|
|
121
|
356
|
|
66
|
|
|
1728
|
return 'GeoIP2::Record::' . ( $key_to_class{$key} || ucfirst $key ); |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |