File Coverage

blib/lib/HTML/Shakan/Filters.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 6 66.6
condition 2 2 100.0
subroutine 5 5 100.0
pod 0 1 0.0
total 31 34 91.1


line stmt bran cond sub pod time code
1             package HTML::Shakan::Filters;
2 1     1   51344 use strict;
  1         2  
  1         23  
3 1     1   5 use warnings;
  1         1  
  1         26  
4 1     1   4 use Scalar::Util 'blessed';
  1         5  
  1         252  
5              
6             sub _get_filter {
7 4     4   6 my $pkg = shift;
8 4 50       16 $pkg = $pkg =~ s/^\+// ? $pkg : "HTML::Shakan::Filter::$pkg";
9 4         17 Mouse::load_class($pkg);
10 4         403 return $pkg->new();
11             }
12              
13             sub filter {
14 5     5 0 30938 my ($class, $filter_ary, $val) = @_;
15 5 50 100     40 $filter_ary = [$filter_ary] unless (ref $filter_ary||'') eq 'ARRAY';
16 5         11 for my $filter (@$filter_ary) {
17 5 100       23 unless (blessed $filter) {
18 4         11 $filter = _get_filter($filter);
19             }
20 5         289 $val = $filter->filter($val);
21             }
22 5         411 $val;
23             }
24              
25             1;
26             __END__