File Coverage

blib/lib/Bootylicious/ArticleByTagIterator.pm
Criterion Covered Total %
statement 22 22 100.0
branch 2 2 100.0
condition n/a
subroutine 7 7 100.0
pod 1 2 50.0
total 32 33 96.9


line stmt bran cond sub pod time code
1             package Bootylicious::ArticleByTagIterator;
2              
3 5     5   459 use strict;
  5         10  
  5         116  
4 5     5   20 use warnings;
  5         9  
  5         112  
5              
6 5     5   22 use base 'Bootylicious::Decorator';
  5         13  
  5         543  
7              
8             __PACKAGE__->attr('tag');
9              
10 5     5   306 use Bootylicious::IteratorSearchable;
  5         12  
  5         31  
11              
12             sub new {
13 5     5 1 29 my $self = shift->SUPER::new(@_);
14              
15 5         14 return $self->build;
16             }
17              
18             sub build {
19 5     5 0 9 my $self = shift;
20              
21 5         13 my $tag = $self->tag;
22              
23             return Bootylicious::IteratorSearchable->new($self->object)->find_all(
24             sub {
25 9     9   40 my ($iterator, $elem) = @_;
26              
27 9 100       13 return unless scalar grep { $_ eq $tag } @{$elem->tags};
  19         77  
  9         25  
28              
29 5         20 return $elem;
30             }
31 5         26 );
32             }
33              
34             1;