FormHandler/Moose.pm

filter: Statementstmt 100% 40 / 40 Branchbran 90.0% 9 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 5 totaltotal 90.7% 59 / 65 CC 8 SCAR 11.4
CC
8
Cov
98%
has_field
6.0
has_page
3.1
BEGIN
1.0
CRAP 3.1
« FormHandler/Field/Compound.pm ↑ Summary FormHandler/Widget/ApplyRole.pm »
1 package HTML::FormHandler::Moose;
2 # ABSTRACT: to add FormHandler sugar
3 148 $HTML::FormHandler::Moose::VERSION = '0.410001';
4 148 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 148 ▶use Moose::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 148 ▶use Moose::Util::MetaRole;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 148 ▶use HTML::FormHandler::Meta::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 148 Moose::Exporter->setup_import_methods(
11 with_meta => [ 'has_field', 'has_page', 'has_block', 'apply' ],
12 also => 'Moose',
13 );
14  
15 sub init_meta {
16 451 ▶ my $class = shift;
Subroutine init_meta: called CC=1 SCAR=0.0
Pod undocumented
17  
18 451 my %options = @_;
19 451 Moose->init_meta(%options);
20 my $meta = Moose::Util::MetaRole::apply_metaroles(
21 for => $options{for_class},
22 451 class_metaroles => {
23 class => [ 'HTML::FormHandler::Meta::Role' ]
24 }
25 );
26 451 return $meta;
27 }
28  
29 sub has_field {
30 844 ▶ my ( $meta, $name, %options ) = @_;
Subroutine has_field: called CC=6 SCAR=17.9
Pod undocumented
31 844 ▶ my $names = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ];
Branch: 1 branch
BranchTrueFalseTotal
ref $name eq 'ARRAY' ? : 1 843 844
32  
33 844 ▶ unless ($meta->found_hfh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($meta->found_hfh) 228 616 844
34 228 my @linearized_isa = $meta->linearized_isa;
35 228 ▶ if( grep { $_ eq 'HTML::FormHandler' || $_ eq 'HTML::FormHandler::Field' } @linearized_isa ) {
Branch: 2 branches
BranchTrueFalseTotal
if (grep {$_ eq 'HTML::FormHandler' or $_ eq 'HTML::FormHandler::Field';} @linearized_isa) { } 227 1 228
$_ eq "HTML::FormHandler" or $_ eq "HTML::FormHandler::Field" 702 214 916
36 227 $meta->found_hfh(1);
37 }
38 else {
39 1 die "Package '" . $linearized_isa[0] . "' uses HTML::FormHandler::Moose without extending HTML::FormHandler[::Field]";
40 }
41 }
42  
43 843 $meta->add_to_field_list( { name => $_, %options } ) for @$names;
44 }
45  
46 sub has_page {
47 3 ▶ my ( $meta, $name, %options ) = @_;
Subroutine has_page: called CC=3 SCAR=11.2
Pod undocumented
48 3 ▶ my $names = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ];
Branch: 1 branch
BranchTrueFalseTotal
ref $name eq 'ARRAY' ? : 0 3 3
49  
50 3 $meta->add_to_page_list( { name => $_, %options } ) for @$names;
51 }
52  
53 sub has_block {
54 13 ▶ my ( $meta, $name, %options ) = @_;
Subroutine has_block: called CC=1 SCAR=0.0
Pod undocumented
55 13 $meta->add_to_block_list( { name => $name, %options } );
56 }
57  
58 sub apply {
59 23 ▶ my ( $meta, $arrayref ) = @_;
Subroutine apply: called CC=1 SCAR=0.0
Pod undocumented
60  
61 23 $meta->add_to_apply_list( @{$arrayref} );
62 }
63  
64 148 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 148 1;
66  
67 __END__
68  
69 =pod
70  
71 =encoding UTF-8
72  
73 =head1 NAME
74  
75 HTML::FormHandler::Moose - to add FormHandler sugar
76  
77 =head1 VERSION
78  
79 version 0.410001
80  
81 =head1 SYNOPSIS
82  
83 Enables the use of field specification sugar (has_field).
84 Use this module instead of C< use Moose; >
85  
86 package MyApp::Form::Foo;
87 use HTML::FormHandler::Moose;
88 extends 'HTML::FormHandler';
89  
90 has_field 'username' => ( type => 'Text', ... );
91 has_field 'something_else' => ( ... );
92  
93 no HTML::FormHandler::Moose;
94 1;
95  
96 =head1 AUTHOR
97  
98 FormHandler Contributors - see HTML::FormHandler
99  
100 =head1 COPYRIGHT AND LICENSE
101  
102 This software is copyright (c) 2017 by Gerda Shank.
103  
104 This is free software; you can redistribute it and/or modify it under
105 the same terms as the Perl 5 programming language system itself.
106  
107 =cut
« FormHandler/Field/Compound.pm ↑ Summary FormHandler/Widget/ApplyRole.pm »