line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Param::Encoding; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
7969
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
77
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
442
|
|
5
|
2
|
|
|
2
|
|
13
|
use base 'Class::Param::Decorator'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
912
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
3112
|
use Encode qw[]; |
|
2
|
|
|
|
|
53750
|
|
|
2
|
|
|
|
|
57
|
|
8
|
2
|
|
|
2
|
|
21
|
use Params::Validate qw[]; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
860
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
1
|
50
|
|
1
|
1
|
4
|
my $class = ref $_[0] ? ref shift : shift; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my ( $decorated, $encoding ) = Params::Validate::validate_with( |
14
|
|
|
|
|
|
|
params => \@_, |
15
|
|
|
|
|
|
|
spec => [ |
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
type => Params::Validate::OBJECT, |
18
|
|
|
|
|
|
|
isa => 'Class::Param::Base', |
19
|
|
|
|
|
|
|
optional => 0 |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
type => Params::Validate::SCALAR, |
23
|
|
|
|
|
|
|
default => 'UTF-8', |
24
|
|
|
|
|
|
|
optional => 1, |
25
|
|
|
|
|
|
|
callbacks => { |
26
|
|
|
|
|
|
|
'valid Encode encoding' => sub { |
27
|
0
|
|
|
0
|
|
0
|
return Encode::find_encoding( $_[0] ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
1
|
|
|
|
|
45
|
], |
32
|
|
|
|
|
|
|
called => "$class\::new" |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
15
|
return bless( [ $decorated, Encode::find_encoding($encoding) ], $class ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
8
|
|
|
8
|
0
|
71
|
sub encoding { return $_[0]->[1] } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get { |
41
|
8
|
|
|
8
|
1
|
699
|
my ( $self, $name ) = @_; |
42
|
|
|
|
|
|
|
|
43
|
8
|
|
|
|
|
14
|
my @values = (); |
44
|
|
|
|
|
|
|
|
45
|
8
|
|
|
|
|
28
|
foreach my $value ( $self->decorated->param($name) ) { |
46
|
|
|
|
|
|
|
|
47
|
10
|
100
|
66
|
|
|
77
|
if ( ref $value || Encode::is_utf8($value) ) { |
48
|
2
|
|
|
|
|
8
|
push @values, $value; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else { |
51
|
8
|
|
|
|
|
19
|
push @values, $self->encoding->decode( $value, Encode::FB_CROAK ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
8
|
100
|
|
|
|
91
|
return @values > 1 ? \@values : $values[0]; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |