lib/Form/Sensible/Field/SubForm.pm

filter: Statementstmt 64.7% 22 / 34 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 63.4% 33 / 52 CC 6 SCAR 15.2
CC
6
Cov
62%
__ANON__
12.0
BUILDARGS
3.0
BUILD
2.0
CRAP 4.6
« lib/Form/Sensible/Form.pm ↑ Summary lib/Form/Sensible/Field.pm »
1 package Form::Sensible::Field::SubForm;
2  
3 16 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 extends 'Form::Sensible::Field';
6  
7 16 has 'form' => (
8 is => 'rw',
9 isa => 'Form::Sensible::Form',
10 required => 1,
11 );
12  
13 2 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=3 SCAR=11.0
Pod documented
14 2 my $class = shift;
15  
16 2 my $args = $_[0];
17 2 ▶ if (!ref($args)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $args) 2 0 2
18 2 $args = { @_ };
19 }
20  
21 ## could probably do this with some sort of coersion - not sure if I want to though.
22 2 ▶ if (ref($args->{'form'}) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args->{"form"} eq "HASH") 1 1 2
23 1 $args->{'form'} = Form::Sensible->create_form($args->{'form'});
24 }
25 2 return $class->SUPER::BUILDARGS($args);
26 }
27  
28 2 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=7.1
Pod documented
29 2 my $self = shift;
30  
31 2 ▶ if (!exists($self->form->render_hints->{'form_template_prefix'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->form->render_hints->{"form_template_prefix"}) 2 0 2
32 2 $self->form->render_hints->{'form_template_prefix'} = 'subform';
33 }
34 }
35  
36 0 ▶around 'value_delegate' => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
37 0 my $orig = shift;
38 0 my $self = shift;
39  
40 0 ▶ return $self->$orig()
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
41 unless @_;
42  
43 0 my $delegate = shift;
44  
45 0 foreach my $field ($self->form->get_fields()) {
46 0 $field->value_delegate( $delegate );
47 }
48 0 return $self->$orig($delegate);
49 16 };
50  
51 0 ▶sub get_additional_configuration {
Subroutine get_additional_configuration: not called CC=1 SCAR=6.9
Pod documented
52 0 my ($self, $template_only) = @_;
53  
54 return {
55 0 'form' => $self->form->flatten($template_only),
56 };
57  
58 }
59  
60 0 ▶around 'validate' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 my $orig = shift;
62 0 my $self = shift;
63  
64 0 return ($self->form->validate(), $self->$orig(@_));
65 16 };
66  
67 16 __PACKAGE__->meta->make_immutable;
68  
69 16 1;
70  
71 __END__
« lib/Form/Sensible/Form.pm ↑ Summary lib/Form/Sensible/Field.pm »