Widget/Filter/Callback.pm untested

filter: Statementstmt 0.0% 0 / 15 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 25 CC 1 SCAR 6.9
CC
1
Cov
0%
filter
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package HTML::Widget::Filter::Callback;
2  
3 use warnings;
4 use strict;
5 use base 'HTML::Widget::Filter';
6  
7 __PACKAGE__->mk_accessors(qw/callback/);
8  
9 *cb = \&callback;
10  
11 =head1 NAME
12  
13 HTML::Widget::Filter::Callback - Lower Case Filter
14  
15 =head1 SYNOPSIS
16  
17 my $f = $widget->filter( 'Callback', 'foo' )->callback(sub {
18 my $value=shift;
19 $value =~ s/before/after/g;
20 return $value;
21 });
22  
23 =head1 DESCRIPTION
24  
25 Callback Filter.
26  
27 =head1 METHODS
28  
29 =head1 callback
30  
31 Argument: \&callback
32  
33 Define the callback to be used for filter.
34  
35 L</cb> is an alias for L</callback>.
36  
37 =head2 filter
38  
39 =cut
40  
41 sub filter {
42 my ( $self, $value ) = @_;
43 my $callback = $self->callback || sub { $_[0] };
44 return $callback->($value);
45 }
46  
47 =head1 AUTHOR
48  
49 Lyo Kato, C<lyo.kato@gmail.com>
50  
51 =head1 LICENSE
52  
53 This library is free software, you can redistribute it and/or modify it under
54 the same terms as Perl itself.
55  
56 =cut
57  
58 1;