| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Data::Printer::Filter; | 
| 2 | 34 |  |  | 34 |  | 228 | use strict; | 
|  | 34 |  |  |  |  | 72 |  | 
|  | 34 |  |  |  |  | 1017 |  | 
| 3 | 34 |  |  | 34 |  | 213 | use warnings; | 
|  | 34 |  |  |  |  | 70 |  | 
|  | 34 |  |  |  |  | 928 |  | 
| 4 | 34 |  |  | 34 |  | 185 | use Data::Printer::Common; | 
|  | 34 |  |  |  |  | 77 |  | 
|  | 34 |  |  |  |  | 1378 |  | 
| 5 | 34 |  |  | 34 |  | 228 | use Scalar::Util; | 
|  | 34 |  |  |  |  | 85 |  | 
|  | 34 |  |  |  |  | 7139 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | sub import { | 
| 8 | 344 |  |  | 344 |  | 884 | my $caller = caller; | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 344 |  |  |  |  | 696 | my %_filters_for  = (); | 
| 11 |  |  |  |  |  |  | my $filter = sub { | 
| 12 | 415 |  |  | 415 |  | 1285 | my ($name, $code) = @_; | 
| 13 | 415 | 50 | 33 |  |  | 3379 | Data::Printer::Common::_die( "syntax: filter 'Class', sub { ... }" ) | 
|  |  |  | 33 |  |  |  |  | 
| 14 |  |  |  |  |  |  | unless defined $name | 
| 15 |  |  |  |  |  |  | && defined $code | 
| 16 |  |  |  |  |  |  | && Scalar::Util::reftype($code) eq 'CODE'; | 
| 17 |  |  |  |  |  |  |  | 
| 18 | 415 |  |  |  |  | 1308 | my $target = Data::Printer::Common::_filter_category_for($name); | 
| 19 | 415 |  |  |  |  | 3083 | unshift @{$_filters_for{$target}{$name}}, sub { | 
| 20 | 635 |  |  | 635 |  | 1157 | my ($item, $ddp) = @_; | 
| 21 | 635 |  |  |  |  | 2149 | $code->($item, $ddp); | 
| 22 | 415 |  |  |  |  | 700 | }; | 
| 23 | 344 |  |  |  |  | 1639 | }; | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | { | 
| 26 | 34 |  |  | 34 |  | 325 | no strict 'refs'; | 
|  | 34 |  |  |  |  | 60 |  | 
|  | 34 |  |  |  |  | 3694 |  | 
|  | 344 |  |  |  |  | 665 |  | 
| 27 | 344 |  |  |  |  | 526 | *{"$caller\::filter"}  = $filter; | 
|  | 344 |  |  |  |  | 1884 |  | 
| 28 | 344 |  |  | 2486 |  | 1077 | *{"$caller\::_filter_list"} = sub { \%_filters_for }; | 
|  | 344 |  |  |  |  | 13032 |  | 
|  | 2486 |  |  |  |  | 5529 |  | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  | }; | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | 1; | 
| 33 |  |  |  |  |  |  | __END__ |