line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::UndefTolerant::Class; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.21'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# applied to metaclass, for Moose >= 1.9900 |
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
27
|
use strict; |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
226
|
|
8
|
7
|
|
|
7
|
|
25
|
use warnings; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
153
|
|
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
23
|
use Moose::Role; |
|
7
|
|
|
|
|
7
|
|
|
7
|
|
|
|
|
41
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# TODO: this code should be in the attribute trait, in the inlined version of |
13
|
|
|
|
|
|
|
# initialize_instance_slot, but this does not yet exist! |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
around _inline_init_attr_from_constructor => sub { |
16
|
|
|
|
|
|
|
my $orig = shift; |
17
|
|
|
|
|
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
my ($attr, $idx) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @source = $self->$orig(@_); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $init_arg = $attr->init_arg; |
23
|
|
|
|
|
|
|
my $type_constraint = $attr->type_constraint; |
24
|
|
|
|
|
|
|
my $tc_says_clean = ($type_constraint && !$type_constraint->check(undef) ? 1 : 0); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# FIXME: not properly sanitizing field names - e.g. consider a field name "Z'ha'dum" |
27
|
|
|
|
|
|
|
return ($tc_says_clean ? ( |
28
|
|
|
|
|
|
|
"if ( exists \$params->{'$init_arg'} && defined \$params->{'$init_arg'} ) {", |
29
|
|
|
|
|
|
|
) : (), |
30
|
|
|
|
|
|
|
@source, |
31
|
|
|
|
|
|
|
$tc_says_clean ? ( |
32
|
|
|
|
|
|
|
'} else {', |
33
|
|
|
|
|
|
|
"delete \$params->{'$init_arg'};", |
34
|
|
|
|
|
|
|
'}', |
35
|
|
|
|
|
|
|
) : (), |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
7
|
|
|
7
|
|
25837
|
no Moose::Role; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
27
|
|
40
|
|
|
|
|
|
|
1; |