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