line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GeoIP2::Role::Model::HasSubdivisions; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
4404
|
use strict; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
258
|
|
4
|
10
|
|
|
10
|
|
43
|
use warnings; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
341
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.006002'; |
7
|
|
|
|
|
|
|
|
8
|
10
|
|
|
10
|
|
47
|
use Moo::Role; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
48
|
|
9
|
|
|
|
|
|
|
|
10
|
10
|
|
|
10
|
|
6613
|
use GeoIP2::Record::Subdivision; |
|
10
|
|
|
|
|
29
|
|
|
10
|
|
|
|
|
392
|
|
11
|
10
|
|
|
10
|
|
68
|
use GeoIP2::Types qw( ArrayRef object_isa_type ); |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
443
|
|
12
|
10
|
|
|
10
|
|
50
|
use Sub::Quote qw( quote_sub ); |
|
10
|
|
|
|
|
61
|
|
|
10
|
|
|
|
|
343
|
|
13
|
|
|
|
|
|
|
|
14
|
10
|
|
|
10
|
|
51
|
use namespace::clean; |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
69
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'GeoIP2::Role::HasLocales'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has _raw_subdivisions => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => ArrayRef, |
21
|
|
|
|
|
|
|
init_arg => 'subdivisions', |
22
|
|
|
|
|
|
|
lazy => 1, |
23
|
|
|
|
|
|
|
default => quote_sub(q{ [] }), |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has _subdivisions => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => ArrayRef, |
29
|
|
|
|
|
|
|
init_arg => undef, |
30
|
|
|
|
|
|
|
lazy => 1, |
31
|
|
|
|
|
|
|
builder => '_build_subdivisions', |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has most_specific_subdivision => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => quote_sub( |
37
|
|
|
|
|
|
|
q{ GeoIP2::Types::object_isa_type( $_[0], 'GeoIP2::Record::Subdivision' ) }, |
38
|
|
|
|
|
|
|
), |
39
|
|
|
|
|
|
|
init_arg => undef, |
40
|
|
|
|
|
|
|
lazy => 1, |
41
|
|
|
|
|
|
|
builder => '_build_most_specific_subdivision', |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub subdivisions { |
45
|
9
|
|
|
9
|
0
|
5820
|
return @{ $_[0]->_subdivisions() }; |
|
9
|
|
|
|
|
159
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _build_subdivisions { |
49
|
5
|
|
|
5
|
|
49
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return [ |
52
|
|
|
|
|
|
|
map { |
53
|
|
|
|
|
|
|
GeoIP2::Record::Subdivision->new( |
54
|
3
|
|
|
|
|
28
|
%{$_}, |
|
3
|
|
|
|
|
36
|
|
55
|
|
|
|
|
|
|
locales => $self->locales(), |
56
|
|
|
|
|
|
|
); |
57
|
5
|
|
|
|
|
8
|
} @{ $self->_raw_subdivisions() } |
|
5
|
|
|
|
|
71
|
|
58
|
|
|
|
|
|
|
]; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _build_most_specific_subdivision { |
62
|
5
|
|
|
5
|
|
5604
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
5
|
|
|
|
|
18
|
my @subdivisions = $self->subdivisions(); |
65
|
5
|
100
|
|
|
|
9648
|
return $subdivisions[-1] if @subdivisions; |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
39
|
return GeoIP2::Record::Subdivision->new( |
68
|
|
|
|
|
|
|
locales => $self->locales(), |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |