FormHandler/Moose/Role.pm

filter: Statementstmt 87.5% 21 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 4 totaltotal 77.1% 27 / 35 CC 1 SCAR 1.3
CC
1
Cov
88%
apply
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« FormHandler/Page.pm ↑ Summary FormHandler/Model.pm »
1 package HTML::FormHandler::Moose::Role;
2 # ABSTRACT: to add sugar to roles
3 6 $HTML::FormHandler::Moose::Role::VERSION = '0.410001';
4 6 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use Moose::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 6 Moose::Exporter->setup_import_methods(
9 with_caller => [ 'has_field', 'has_block', 'apply' ],
10 also => 'Moose::Role',
11 );
12  
13 sub init_meta {
14 9 ▶ my $class = shift;
Subroutine init_meta: called CC=1 SCAR=0.0
Pod undocumented
15  
16 9 my %options = @_;
17 9 Moose::Role->init_meta(%options);
18 my $meta = Moose::Util::MetaRole::apply_metaroles(
19 for => $options{for_class},
20 9 role_metaroles => { role => ['HTML::FormHandler::Meta::Role'] }
21 );
22  
23 9 return $meta;
24 }
25  
26 sub has_field {
27 39 ▶ my ( $class, $name, %options ) = @_;
Subroutine has_field: called CC=1 SCAR=0.0
Pod undocumented
28  
29 39 $class->meta->add_to_field_list( { name => $name, %options } );
30 }
31  
32 sub has_block {
33 3 ▶ my ( $class, $name, %options ) = @_;
Subroutine has_block: called CC=1 SCAR=0.0
Pod undocumented
34 3 $class->meta->add_to_block_list( { name => $name, %options } );
35 }
36  
37 sub apply {
38 0 ▶ my ( $class, $arrayref ) = @_;
Subroutine apply: not called CC=1 SCAR=6.9
Pod undocumented
39 0 $class->meta->add_to_apply_list( @{$arrayref} );
40 }
41  
42 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 6 1;
44  
45 __END__
46  
47 =pod
48  
49 =encoding UTF-8
50  
51 =head1 NAME
52  
53 HTML::FormHandler::Moose::Role - to add sugar to roles
54  
55 =head1 VERSION
56  
57 version 0.410001
58  
59 =head1 SYNOPSIS
60  
61 Enables the use of field specification sugar (has_field) in roles.
62 Use this module instead of C< use Moose::Role; >
63  
64 package MyApp::Form::Foo;
65 use HTML::FormHandler::Moose::Role;
66  
67 has_field 'username' => ( type => 'Text', ... );
68 has_field 'something_else' => ( ... );
69  
70 no HTML::FormHandler::Moose::Role;
71 1;
72  
73 =head1 AUTHOR
74  
75 FormHandler Contributors - see HTML::FormHandler
76  
77 =head1 COPYRIGHT AND LICENSE
78  
79 This software is copyright (c) 2017 by Gerda Shank.
80  
81 This is free software; you can redistribute it and/or modify it under
82 the same terms as the Perl 5 programming language system itself.
83  
84 =cut
« FormHandler/Page.pm ↑ Summary FormHandler/Model.pm »