line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormFu::Filter::Callback; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
513
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
124
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
12
|
use Moose; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
19
|
|
7
|
3
|
|
|
3
|
|
12115
|
use MooseX::Attribute::FormFuChained; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
256
|
|
8
|
|
|
|
|
|
|
extends 'HTML::FormFu::Filter'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has callback => ( is => 'rw', traits => ['FormFuChained'] ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub filter { |
13
|
4
|
|
|
4
|
0
|
5
|
my ( $self, $value, $params ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
100
|
1
|
|
79
|
my $callback = $self->callback || sub {$value}; |
|
1
|
|
|
|
|
3
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
## no critic (ProhibitNoStrict); |
18
|
3
|
|
|
3
|
|
11
|
no strict 'refs'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
194
|
|
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
10
|
return $callback->( $value, $params ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__END__ |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
HTML::FormFu::Filter::Callback - filter with custom subroutine |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 VERSION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
version 2.05 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$field->filter({ |
40
|
|
|
|
|
|
|
type => 'Callback', |
41
|
|
|
|
|
|
|
callback => \&my_filter, |
42
|
|
|
|
|
|
|
}); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
--- |
45
|
|
|
|
|
|
|
elements: |
46
|
|
|
|
|
|
|
- type: Text |
47
|
|
|
|
|
|
|
name: foo |
48
|
|
|
|
|
|
|
filters: |
49
|
|
|
|
|
|
|
- type: Callback |
50
|
|
|
|
|
|
|
callback: "main::my_filter" |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub my_filter { |
53
|
|
|
|
|
|
|
my ($value) = @_; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# do something to $value |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return $value; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Filter using a user-provided subroutine. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 METHODS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 callback |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Arguments: \&code-reference |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Arguments: "subroutine-name" |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AUTHOR |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Carl Franks, C<cfranks@cpan.org> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Based on the original source code of L<HTML::Widget::Filter::Callback>, by |
77
|
|
|
|
|
|
|
Lyo Kato, C<lyo.kato@gmail.com> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 LICENSE |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
82
|
|
|
|
|
|
|
the same terms as Perl itself. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |