line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Tiny::Plugin::Diva; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
1338794
|
use v5.10; |
|
4
|
|
|
|
|
27
|
|
4
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
78
|
|
5
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
198
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1842
|
use Form::Tiny::Plugin::Diva::Adapter; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
151
|
|
10
|
4
|
|
|
4
|
|
2317
|
use Form::Tiny::Plugin::Diva::MetaRole; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
131
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
26
|
use parent 'Form::Tiny::Plugin'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
22
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub plugin |
15
|
|
|
|
|
|
|
{ |
16
|
4
|
|
|
4
|
1
|
161
|
my ($self, $caller, $context) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
return { |
19
|
|
|
|
|
|
|
subs => { |
20
|
|
|
|
|
|
|
diva_config => sub { |
21
|
2
|
|
|
2
|
|
1279
|
$$context = undef; |
22
|
2
|
|
|
|
|
9
|
$caller->form_meta->add_diva_config(@_); |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
42
|
roles => [__PACKAGE__], |
27
|
|
|
|
|
|
|
meta_roles => ['Form::Tiny::Plugin::Diva::MetaRole'], |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
4
|
|
3356
|
use Scalar::Util qw(weaken); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
216
|
|
32
|
4
|
|
|
4
|
|
26
|
use Moo::Role; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
33
|
|
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
|
|
28866
|
my ($self) = @_; |
44
|
4
|
|
|
|
|
11
|
my %config = %{$self->form_meta->diva_config}; |
|
4
|
|
|
|
|
18
|
|
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
17
|
my @fields; |
47
|
|
|
|
|
|
|
my @hidden; |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
8
|
for my $field (@{$self->field_defs}) { |
|
4
|
|
|
|
|
87
|
|
50
|
|
|
|
|
|
|
my %field_data = ( |
51
|
12
|
|
100
|
|
|
269
|
%{$field->data // {type => 'hidden'}}, |
|
12
|
|
|
|
|
98
|
|
52
|
|
|
|
|
|
|
name => $field->name, |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
12
|
100
|
100
|
|
|
58
|
if ($field->has_default && !exists $field_data{d} && !exists $field_data{default}) { |
|
|
|
66
|
|
|
|
|
56
|
2
|
|
|
|
|
11
|
$field_data{default} = $field->default->($self); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
12
|
|
66
|
|
|
52
|
my $type = $field_data{type} // $field_data{t}; |
60
|
12
|
100
|
|
|
|
53
|
my $push_to = lc $type eq 'hidden' ? \@hidden : \@fields; |
61
|
12
|
|
|
|
|
67
|
push @$push_to, {%field_data, comment => \%field_data}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
4
|
|
|
|
|
19
|
weaken $self; |
65
|
4
|
|
|
|
|
60
|
return Form::Tiny::Plugin::Diva::Adapter->new( |
66
|
|
|
|
|
|
|
%config, |
67
|
|
|
|
|
|
|
form => \@fields, |
68
|
|
|
|
|
|
|
hidden => \@hidden, |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
form_instance => $self, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |