| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::FormFu::Role::Populate; |
|
2
|
|
|
|
|
|
|
|
|
3
|
401
|
|
|
401
|
|
235275
|
use strict; |
|
|
401
|
|
|
|
|
1567
|
|
|
|
401
|
|
|
|
|
18201
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
401
|
|
|
401
|
|
1614
|
use Moose::Role; |
|
|
401
|
|
|
|
|
1380
|
|
|
|
401
|
|
|
|
|
5986
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
401
|
|
|
401
|
|
1464407
|
use Scalar::Util qw( reftype ); |
|
|
401
|
|
|
|
|
1519
|
|
|
|
401
|
|
|
|
|
18278
|
|
|
9
|
401
|
|
|
401
|
|
2458
|
use Carp qw( croak ); |
|
|
401
|
|
|
|
|
1496
|
|
|
|
401
|
|
|
|
|
145158
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
after BUILD => sub { |
|
12
|
|
|
|
|
|
|
my ( $self, $args ) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$args ||= {}; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# get args handled by Moose so they aren't set twice |
|
17
|
|
|
|
|
|
|
my %init_args = |
|
18
|
|
|
|
|
|
|
map { $_->{init_arg} => 1 } |
|
19
|
|
|
|
|
|
|
grep { defined $_->{init_arg} } |
|
20
|
|
|
|
|
|
|
$self->meta->get_all_attributes; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# remove defaults set in HTML::FormFu::BUILD because they need to be set for a third time |
|
23
|
|
|
|
|
|
|
delete @init_args{ keys %{$HTML::FormFu::build_defaults} }; |
|
24
|
|
|
|
|
|
|
my %args |
|
25
|
|
|
|
|
|
|
= map { $_ => $args->{$_} } grep { !exists $init_args{$_} } keys %$args; |
|
26
|
|
|
|
|
|
|
$self->populate( \%args ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return; |
|
29
|
|
|
|
|
|
|
}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub populate { |
|
32
|
6856
|
|
|
6856
|
0
|
8368
|
my ( $self, $arg_ref ) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
6856
|
50
|
|
|
|
22801
|
croak "argument to populate() must be a hash-ref" |
|
35
|
|
|
|
|
|
|
if reftype($arg_ref) ne 'HASH'; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# shallow clone the args so we don't stomp on them |
|
38
|
6856
|
|
|
|
|
16360
|
my %args = %$arg_ref; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# we have to handle element_defaults seperately, as it is no longer a |
|
41
|
|
|
|
|
|
|
# simple hash key |
|
42
|
|
|
|
|
|
|
|
|
43
|
6856
|
50
|
|
|
|
13221
|
if ( exists $args{element_defaults} ) { |
|
44
|
0
|
|
|
|
|
0
|
$self->element_defaults( delete $args{element_defaults} ); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# handle any 'roles' first |
|
48
|
6856
|
|
|
|
|
7744
|
my $roles = delete $args{roles}; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# notes for @defer_keys... |
|
51
|
|
|
|
|
|
|
# 'options', 'values', 'value_range' is for _Group elements, |
|
52
|
|
|
|
|
|
|
# to ensure any 'empty_first' value gets set first |
|
53
|
|
|
|
|
|
|
|
|
54
|
6856
|
|
|
|
|
26320
|
my @defer_keys = qw( |
|
55
|
|
|
|
|
|
|
default_args |
|
56
|
|
|
|
|
|
|
auto_fieldset |
|
57
|
|
|
|
|
|
|
load_config_file |
|
58
|
|
|
|
|
|
|
element elements |
|
59
|
|
|
|
|
|
|
default_values |
|
60
|
|
|
|
|
|
|
filter filters |
|
61
|
|
|
|
|
|
|
constraint constraints |
|
62
|
|
|
|
|
|
|
inflator inflators |
|
63
|
|
|
|
|
|
|
deflator deflators |
|
64
|
|
|
|
|
|
|
query |
|
65
|
|
|
|
|
|
|
validator validators |
|
66
|
|
|
|
|
|
|
transformer transformers |
|
67
|
|
|
|
|
|
|
plugins |
|
68
|
|
|
|
|
|
|
options |
|
69
|
|
|
|
|
|
|
values |
|
70
|
|
|
|
|
|
|
value_range |
|
71
|
|
|
|
|
|
|
); |
|
72
|
|
|
|
|
|
|
|
|
73
|
6856
|
|
|
|
|
6332
|
my %defer; |
|
74
|
6856
|
|
|
|
|
9667
|
for (@defer_keys) { |
|
75
|
157688
|
100
|
|
|
|
187009
|
$defer{$_} = delete $args{$_} if exists $args{$_}; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
6856
|
|
|
|
|
7661
|
eval { |
|
79
|
6856
|
100
|
|
|
|
11152
|
if ( $roles ) { |
|
80
|
3
|
|
|
|
|
22
|
$self->roles( $roles ); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
6856
|
|
|
|
|
9220
|
map { $self->$_( delete $args{$_} ) } keys %args; |
|
|
6350
|
|
|
|
|
74645
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
601
|
|
|
|
|
3286
|
map { $self->$_( $defer{$_} ) } |
|
86
|
6855
|
|
|
|
|
8802
|
grep { exists $defer{$_} } @defer_keys; |
|
|
157665
|
|
|
|
|
127156
|
|
|
87
|
|
|
|
|
|
|
}; |
|
88
|
6856
|
100
|
|
|
|
11480
|
croak $@ if $@; |
|
89
|
|
|
|
|
|
|
|
|
90
|
6855
|
|
|
|
|
17429
|
return $self; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |