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