File Coverage

blib/lib/Form/Factory/Feature/Role/Clean.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Form::Factory::Feature::Role::Clean;
2             $Form::Factory::Feature::Role::Clean::VERSION = '0.022';
3 1     1   412 use Moose::Role;
  1         1  
  1         6  
4              
5             requires qw( clean );
6              
7             # ABSTRACT: features that clean up control values
8              
9              
10             1;
11              
12             __END__
13              
14             =pod
15              
16             =encoding UTF-8
17              
18             =head1 NAME
19              
20             Form::Factory::Feature::Role::Clean - features that clean up control values
21              
22             =head1 VERSION
23              
24             version 0.022
25              
26             =head1 SYNOPSIS
27              
28             package MyApp::Feature::Foo;
29             use Moose;
30              
31             with qw(
32             Form::Factory::Feature
33             Form::Factory::Feature::Role::Control
34             Form::Factory::Feature::Role::Clean
35             );
36              
37             sub clean {
38             my $self = shift;
39              
40             # Clean up the value, replace it with Foo
41             $self->control->{something}->current_value('Foo');
42             }
43              
44             package Form::Factory::Feature::Foo;
45             sub register_implementation { 'MyApp::Feature::Foo' }
46              
47             =head1 DESCRIPTION
48              
49             This is for features that run during the clean phase. This runs immediately after the input has been consumed and before it is checked. These features should avoid reporting errors. The intention is for these features to clean up the input automatically before it is checked for errors. This should work with the control values rather than the action attributes directly, since those won't be set yet.
50              
51             It is possible for the C<clean> method to stop processing by marking the result as invalid, but it is better to do that using L<Form::Factory::Feature::Role::Clean>.
52              
53             =head1 ROLE METHODS
54              
55             =head2 clean
56              
57             This is called immediately after input has been consumed and before the input is checked for errors. This method should be used to clean up the input. It should not be used to validate the input since other clean methods may run after this one and the input is not yet in its final state.
58              
59             The method will receive no arguments except the object it is called upon and the return value is ignored. Any output it needs to send should be placed in the C<result> object.
60              
61             =head1 AUTHOR
62              
63             Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
64              
65             =head1 COPYRIGHT AND LICENSE
66              
67             This software is copyright (c) 2015 by Qubling Software LLC.
68              
69             This is free software; you can redistribute it and/or modify it under
70             the same terms as the Perl 5 programming language system itself.
71              
72             =cut