line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Tiny::Plugin::Diva; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
909782
|
use v5.10; |
|
4
|
|
|
|
|
20
|
|
4
|
4
|
|
|
4
|
|
16
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
60
|
|
5
|
4
|
|
|
4
|
|
57
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
189
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1340
|
use Form::Tiny::Plugin::Diva::Adapter; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
104
|
|
10
|
4
|
|
|
4
|
|
1606
|
use Form::Tiny::Plugin::Diva::MetaRole; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
95
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
21
|
use parent 'Form::Tiny::Plugin'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
15
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub plugin |
15
|
|
|
|
|
|
|
{ |
16
|
4
|
|
|
4
|
1
|
120
|
my ($self, $caller, $context) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
return { |
19
|
|
|
|
|
|
|
subs => { |
20
|
|
|
|
|
|
|
diva_config => sub { |
21
|
2
|
|
|
2
|
|
399
|
$$context = undef; |
22
|
2
|
|
|
|
|
7
|
$caller->form_meta->add_diva_config(@_); |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
40
|
roles => [__PACKAGE__], |
27
|
|
|
|
|
|
|
meta_roles => ['Form::Tiny::Plugin::Diva::MetaRole'], |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
4
|
|
2402
|
use Scalar::Util qw(weaken); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
157
|
|
32
|
4
|
|
|
4
|
|
18
|
use Moo::Role; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
18
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'diva' => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
builder => '_build_diva', |
37
|
|
|
|
|
|
|
lazy => 1, |
38
|
|
|
|
|
|
|
init_arg => undef, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _build_diva |
42
|
|
|
|
|
|
|
{ |
43
|
4
|
|
|
4
|
|
14589
|
my ($self) = @_; |
44
|
4
|
|
|
|
|
9
|
my %config = %{$self->form_meta->diva_config}; |
|
4
|
|
|
|
|
15
|
|
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
13
|
my @fields; |
47
|
|
|
|
|
|
|
my @hidden; |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
6
|
for my $field (@{$self->field_defs}) { |
|
4
|
|
|
|
|
62
|
|
50
|
|
|
|
|
|
|
my %field_data = ( |
51
|
12
|
|
100
|
|
|
186
|
%{$field->data // {type => 'hidden'}}, |
|
12
|
|
|
|
|
99
|
|
52
|
|
|
|
|
|
|
name => $field->name, |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
12
|
100
|
100
|
|
|
48
|
if ($field->has_default && !exists $field_data{d} && !exists $field_data{default}) { |
|
|
|
66
|
|
|
|
|
56
|
2
|
|
|
|
|
7
|
$field_data{default} = $field->default->($self); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
12
|
|
66
|
|
|
32
|
my $type = $field_data{type} // $field_data{t}; |
60
|
12
|
100
|
|
|
|
30
|
my $push_to = lc $type eq 'hidden' ? \@hidden : \@fields; |
61
|
12
|
|
|
|
|
43
|
push @$push_to, {%field_data, comment => \%field_data}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
4
|
|
|
|
|
48
|
my $obj = Form::Tiny::Plugin::Diva::Adapter->new( |
65
|
|
|
|
|
|
|
%config, |
66
|
|
|
|
|
|
|
form => \@fields, |
67
|
|
|
|
|
|
|
hidden => \@hidden, |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
form_instance => $self, |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
4
|
|
|
|
|
1044
|
weaken $obj->{form_instance}; |
73
|
4
|
|
|
|
|
23
|
return $obj; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |