line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormHandler::Moose; |
2
|
|
|
|
|
|
|
# ABSTRACT: to add FormHandler sugar |
3
|
|
|
|
|
|
|
|
4
|
106
|
|
|
106
|
|
9342700
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Moose::Exporter; |
6
|
|
|
|
|
|
|
use Moose::Util::MetaRole; |
7
|
|
|
|
|
|
|
use HTML::FormHandler::Meta::Role; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
my $class = shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %options = @_; |
19
|
|
|
|
|
|
|
Moose->init_meta(%options); |
20
|
|
|
|
|
|
|
my $meta = Moose::Util::MetaRole::apply_metaroles( |
21
|
|
|
|
|
|
|
for => $options{for_class}, |
22
|
|
|
|
|
|
|
class_metaroles => { |
23
|
|
|
|
|
|
|
class => [ 'HTML::FormHandler::Meta::Role' ] |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
return $meta; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub has_field { |
30
|
|
|
|
|
|
|
my ( $meta, $name, %options ) = @_; |
31
|
|
|
|
|
|
|
my $names = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ]; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
unless ($meta->found_hfh) { |
34
|
|
|
|
|
|
|
my @linearized_isa = $meta->linearized_isa; |
35
|
|
|
|
|
|
|
if( grep { $_ eq 'HTML::FormHandler' || $_ eq 'HTML::FormHandler::Field' } @linearized_isa ) { |
36
|
|
|
|
|
|
|
$meta->found_hfh(1); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
|
|
|
|
|
|
die "Package '" . $linearized_isa[0] . "' uses HTML::FormHandler::Moose without extending HTML::FormHandler[::Field]"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$meta->add_to_field_list( { name => $_, %options } ) for @$names; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub has_page { |
47
|
|
|
|
|
|
|
my ( $meta, $name, %options ) = @_; |
48
|
|
|
|
|
|
|
my $names = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ]; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$meta->add_to_page_list( { name => $_, %options } ) for @$names; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub has_block { |
54
|
|
|
|
|
|
|
my ( $meta, $name, %options ) = @_; |
55
|
|
|
|
|
|
|
$meta->add_to_block_list( { name => $name, %options } ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub apply { |
59
|
|
|
|
|
|
|
my ( $meta, $arrayref ) = @_; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$meta->add_to_apply_list( @{$arrayref} ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
use namespace::autoclean; |
65
|
|
|
|
|
|
|
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.40057 |
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) 2014 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 |