| 1 | package Data::Partial::Google; | ||||||||||||||||||||
| 2 | # ABSTRACT: Filter data structures for "partial responses," Google style | ||||||||||||||||||||
| 3 | 2 | our $VERSION = '0.02'; # VERSION | |||||||||||||||||||
| 4 | 2 | our $AUTHORITY = 'cpan:ARODLAND'; # AUTHORITY | |||||||||||||||||||
| 5 | 2 | ▶ | use Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 2 | ▶ | use Data::Partial::Google::Parser; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 2 | ▶ | use Data::Partial::Google::Filter; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 2 | has rule => ( | |||||||||||||||||||
| 11 | is => 'ro', | ||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | has filter => ( | ||||||||||||||||||||
| 15 | is => 'ro', | ||||||||||||||||||||
| 16 | lazy => 1, | ||||||||||||||||||||
| 17 | 23 | ▶ | default => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 23 | Data::Partial::Google::Parser->parse(shift->rule) | |||||||||||||||||||
| 19 | }, | ||||||||||||||||||||
| 20 | 2 | ); | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | # Allow Data::Partial::Google->new("a,b(c/d)") | ||||||||||||||||||||
| 23 | 25 | ▶ | sub BUILDARGS { | ||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||
| 24 | 25 | my ($class, @args) = @_; | |||||||||||||||||||
| 25 | 25 | ▶ | unshift @args, "rule" if @args % 2; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 25 | return { @args }; | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 50 | ▶ | sub has_rule { | ||||||||||||||||||
|
Subroutine
has_rule: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 30 | 50 | my ($self) = @_; | |||||||||||||||||||
| 31 | 50 | my $rule = $self->rule; | |||||||||||||||||||
| 32 | 50 | ▶ | return defined $rule && length $rule; | ||||||||||||||||||
|
Condition100%3/3
defined $rule && length $rule
MC/DC100%2/2
defined $rule && length $rule
defined $rule
length $rule
Truth table100%3/3
A && B
A= defined $ruleB= length $rule
| |||||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 25 | ▶ | sub BUILD { | ||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 36 | 25 | my ($self) = @_; | |||||||||||||||||||
| 37 | 25 | ▶ | $self->filter if $self->has_rule; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 25 | ▶ | sub mask { | ||||||||||||||||||
|
Subroutine
mask: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 41 | 25 | my ($self, $obj) = @_; | |||||||||||||||||||
| 42 | 25 | ▶ | if ($self->has_rule) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 43 | 23 | return $self->filter->mask($obj); | |||||||||||||||||||
| 44 | } else { | ||||||||||||||||||||
| 45 | 2 | return $obj; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 2 | 1; | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||