File Coverage

blib/lib/HTML/Shakan/Filters.pm
Criterion Covered Total %
statement 20 20 100.0
branch 5 6 83.3
condition 2 2 100.0
subroutine 5 5 100.0
pod 0 1 0.0
total 32 34 94.1


line stmt bran cond sub pod time code
1             package HTML::Shakan::Filters;
2 23     23   53741 use strict;
  23         43  
  23         675  
3 23     23   108 use warnings;
  23         36  
  23         591  
4 23     23   108 use Scalar::Util 'blessed';
  23         38  
  23         5284  
5              
6             sub _get_filter {
7 7     7   14 my $pkg = shift;
8 7 50       31 $pkg = $pkg =~ s/^\+// ? $pkg : "HTML::Shakan::Filter::$pkg";
9 7         33 Mouse::load_class($pkg);
10 7         593 return $pkg->new();
11             }
12              
13             sub filter {
14 49     49 0 43538 my ($class, $filter_ary, $val) = @_;
15 49 100 100     276 $filter_ary = [$filter_ary] unless (ref $filter_ary||'') eq 'ARRAY';
16 49         153 for my $filter (@$filter_ary) {
17 8 100       50 unless (blessed $filter) {
18 7         20 $filter = _get_filter($filter);
19             }
20 8         470 $val = $filter->filter($val);
21             }
22 49         889 $val;
23             }
24              
25             1;
26             __END__