« blib/lib/Dancer/Plugin/Params/Normalization.pm
↑ Summary
lib/Dancer/Plugin/Params/Normalization/Abstract.pm »
| 1 | # | ||
| 2 | # This file is part of Dancer-Plugin-Params-Normalization | ||
| 3 | # | ||
| 4 | # This software is copyright (c) 2011 by Damien "dams" Krotkine. | ||
| 5 | # | ||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||
| 8 | # | ||
| 9 | package Dancer::Plugin::Params::Normalization::Trim; | ||
| 10 | { | ||
| 11 | 1 | $Dancer::Plugin::Params::Normalization::Trim::VERSION = '0.52'; | |
| 12 | } | ||
| 13 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | # TRIM: normalization class for white space filtering | ||
| 17 | |||
| 18 | 1 | ▶ | use base 'Dancer::Plugin::Params::Normalization::Abstract'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | |||
| 20 | #set the trim_filter | ||
| 21 | 0 | ▶ | my $trim_filter = sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 22 | 0 | return scalar($_[0] =~ s/^\s+|\s+$//g) | |
| 23 | 1 | }; | |
| 24 | |||
| 25 | 0 | ▶ | sub normalize { |
|
Subroutine
normalize: not called CC=2 SCAR=17.9
Pod
documented
| |||
| 26 | 0 | my ($self, $params) = @_; | |
| 27 | 0 | $trim_filter->($_) for values %$params; | |
| 28 | 0 | return $params; | |
| 29 | } | ||
| 30 | |||
| 31 | 1 | 1; | |
| 32 | |||
| 33 | __END__ | ||