File Coverage

lib/CatalystX/Resource/TraitFor/Controller/Resource/MergeUploadParams.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package CatalystX::Resource::TraitFor::Controller::Resource::MergeUploadParams;
2             $CatalystX::Resource::TraitFor::Controller::Resource::MergeUploadParams::VERSION = '0.03';
3 9     9   13984 use MooseX::MethodAttributes::Role;
  9         28  
  9         79  
4 9     9   85410 use namespace::autoclean;
  9         36  
  9         76  
5              
6             # ABSTRACT: merge upload params into request params
7              
8             requires qw/
9             form
10             /;
11              
12              
13             before 'form' => sub {
14             my ( $self, $c, $activate_fields ) = @_;
15              
16             # for each upload put the Catalyst::Request::Upload object into $params
17             if ( $c->req->method eq 'POST' ) {
18             while (my ($param_name, $upload) = each %{$c->req->uploads}) {
19             $c->req->params->{$param_name} = $upload;
20             }
21             }
22             };
23              
24             1;
25              
26             __END__
27              
28             =pod
29              
30             =encoding UTF-8
31              
32             =head1 NAME
33              
34             CatalystX::Resource::TraitFor::Controller::Resource::MergeUploadParams - merge upload params into request params
35              
36             =head1 VERSION
37              
38             version 0.03
39              
40             =head1 METHOD MODIFIERS
41              
42             =head2 before 'form'
43              
44             merge $c->req->uploads into $c->req->params
45              
46             Makes Catalyst::Request::Upload objects available in
47             HTML::FormHandler::params
48              
49             You might need this if you are using HTML::FormHandler
50             and DBIx::Class::InflateColumn::FS
51              
52             =head1 AUTHOR
53              
54             David Schmidt <davewood@cpan.org>
55              
56             =head1 COPYRIGHT AND LICENSE
57              
58             This software is copyright (c) 2011 by David Schmidt.
59              
60             This is free software; you can redistribute it and/or modify it under
61             the same terms as the Perl 5 programming language system itself.
62              
63             =cut