line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Partial::Google; |
2
|
|
|
|
|
|
|
# ABSTRACT: Filter data structures for "partial responses," Google style |
3
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
4
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:ARODLAND'; # AUTHORITY |
5
|
2
|
|
|
2
|
|
227409
|
use Moo; |
|
2
|
|
|
|
|
46162
|
|
|
2
|
|
|
|
|
18
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
8192
|
use Data::Partial::Google::Parser; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
187
|
|
8
|
2
|
|
|
2
|
|
1764
|
use Data::Partial::Google::Filter; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
683
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has rule => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has filter => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
default => sub { |
18
|
|
|
|
|
|
|
Data::Partial::Google::Parser->parse(shift->rule) |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Allow Data::Partial::Google->new("a,b(c/d)") |
23
|
|
|
|
|
|
|
sub BUILDARGS { |
24
|
25
|
|
|
25
|
0
|
96021
|
my ($class, @args) = @_; |
25
|
25
|
50
|
|
|
|
175
|
unshift @args, "rule" if @args % 2; |
26
|
25
|
|
|
|
|
659
|
return { @args }; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub has_rule { |
30
|
50
|
|
|
50
|
0
|
80
|
my ($self) = @_; |
31
|
50
|
|
|
|
|
158
|
my $rule = $self->rule; |
32
|
50
|
|
100
|
|
|
913
|
return defined $rule && length $rule; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub BUILD { |
36
|
25
|
|
|
25
|
0
|
415
|
my ($self) = @_; |
37
|
25
|
100
|
|
|
|
83
|
$self->filter if $self->has_rule; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub mask { |
41
|
25
|
|
|
25
|
1
|
21302
|
my ($self, $obj) = @_; |
42
|
25
|
100
|
|
|
|
85
|
if ($self->has_rule) { |
43
|
23
|
|
|
|
|
601
|
return $self->filter->mask($obj); |
44
|
|
|
|
|
|
|
} else { |
45
|
2
|
|
|
|
|
5
|
return $obj; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |