lib/HTML/FormFu/Transformer/Callback.pm

filter: Statementstmt 95.4% 21 / 22 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 79.4% 27 / 34 SCAR 7.0
CC
2
Cov
88%
transformer
2.1
__ANON__
1.2
BEGIN
1.0
CRAP 2.0
« lib/HTML/FormFu/Constraint/Callback.pm ↑ Summary lib/HTML/FormFu/Validator/Callback.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Transformer::Callback;
4 3 $HTML::FormFu::Transformer::Callback::VERSION = '2.06';
5 # ABSTRACT: Callback transformer
6  
7 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use MooseX::Attribute::Chained;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 extends 'HTML::FormFu::Transformer';
10  
11 3 has callback => ( is => 'rw', traits => ['Chained'] );
12  
13 sub transformer {
14 9 ▶ my ( $self, $value, $params ) = @_;
Subroutine transformer: called CC=2 SCAR=7.3
Pod undocumented
15  
16 9 ▶ my $callback = $self->callback || sub {1};
Subroutine __ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$self->callback || sub {
l!l&&r!l&&!r
900
MC/DC0%0/2
$self->callback || sub { 1; }
$self->callback sub { 1; }
Truth table33%1/3
A || B
A= $self->callbackB= sub { 1; }
ABresult
1X1
011
000
17  
18 ## no critic (ProhibitNoStrict);
19 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 9 my $return = $callback->( $value, $params );
22  
23 9 return $return;
24 }
25  
26 3 __PACKAGE__->meta->make_immutable;
27  
28 3 1;
29  
30 __END__
31  
32 =pod
33  
34 =encoding UTF-8
35  
36 =head1 NAME
37  
38 HTML::FormFu::Transformer::Callback - Callback transformer
39  
40 =head1 VERSION
41  
42 version 2.06
43  
44 =head1 SYNOPSIS
45  
46 $field->transformer('Callback')->callback( \&my_transformer );
47  
48 ---
49 elements:
50 - type: Text
51 name: foo
52 transformers:
53 - type: Callback
54 callback: "main::my_transformer"
55  
56 =head1 DESCRIPTION
57  
58 The first argument passed to the callback is the submitted value for the
59 associated field. The second argument passed to the callback is a hashref of
60 name/value pairs for all input fields.
61  
62 =head1 METHODS
63  
64 =head2 callback
65  
66 Arguments: \&code-reference
67  
68 Arguments: "subroutine-name"
69  
70 =head1 SEE ALSO
71  
72 Is a sub-class of, and inherits methods from L<HTML::FormFu::Transformer>
73  
74 L<HTML::FormFu>
75  
76 =head1 AUTHOR
77  
78 Carl Franks C<cfranks@cpan.org>
79  
80 =head1 LICENSE
81  
82 This library is free software, you can redistribute it and/or modify it under
83 the same terms as Perl itself.
84  
85 =head1 AUTHOR
86  
87 Carl Franks <cpan@fireartist.com>
88  
89 =head1 COPYRIGHT AND LICENSE
90  
91 This software is copyright (c) 2018 by Carl Franks.
92  
93 This is free software; you can redistribute it and/or modify it under
94 the same terms as the Perl 5 programming language system itself.
95  
96 =cut
« lib/HTML/FormFu/Constraint/Callback.pm ↑ Summary lib/HTML/FormFu/Validator/Callback.pm »