line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Factory::Interface; |
2
|
|
|
|
|
|
|
$Form::Factory::Interface::VERSION = '0.022'; |
3
|
1
|
|
|
1
|
|
16889
|
use Moose::Role; |
|
1
|
|
|
|
|
3227
|
|
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4229
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
6
|
1
|
|
|
1
|
|
4
|
use Class::Load; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
7
|
1
|
|
|
1
|
|
428
|
use Form::Factory::Stasher::Memory; |
|
1
|
|
|
|
|
274
|
|
|
1
|
|
|
|
|
306
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
requires qw( render_control consume_control ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Role for form interface implementations |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has stasher => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
does => 'Form::Factory::Stasher', |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
default => sub { Form::Factory::Stasher::Memory->new }, |
19
|
|
|
|
|
|
|
handles => [ qw( stash unstash ) ], |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new_action { |
24
|
14
|
|
|
14
|
1
|
6160
|
my ($self, $class_name, $args) = @_; |
25
|
|
|
|
|
|
|
|
26
|
14
|
50
|
|
|
|
47
|
Class::Load::load_class($class_name) |
27
|
|
|
|
|
|
|
or Carp::croak("cannot load $class_name: $@"); |
28
|
|
|
|
|
|
|
|
29
|
14
|
|
|
|
|
592
|
return $class_name->new( %$args, form_interface => $self ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new_control { |
34
|
78
|
|
|
78
|
1
|
138
|
my ($self, $name, $args) = @_; |
35
|
|
|
|
|
|
|
|
36
|
78
|
|
|
|
|
287
|
my $class_name = Form::Factory->control_class($name); |
37
|
78
|
50
|
|
|
|
174
|
return unless $class_name; |
38
|
|
|
|
|
|
|
|
39
|
78
|
|
|
|
|
3171
|
return $class_name->new($args); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=pod |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=encoding UTF-8 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Form::Factory::Interface - Role for form interface implementations |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 VERSION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
version 0.022 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SYNOPSIS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
package MyApp::Interface::MyUI; |
62
|
|
|
|
|
|
|
use Moose; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
with qw( Form::Factory::Interface ); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub render_control { |
67
|
|
|
|
|
|
|
my ($self, $control, %options) = @_; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Draw $control for user |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub consume_control { |
73
|
|
|
|
|
|
|
my ($self, $control, %options) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Consume values from user to fill $control |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
package Form::Factory::Interface::Custom::MyUI; |
79
|
|
|
|
|
|
|
sub register_implementation { 'MyApp::Interface::MyUI' } |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Defines the contract form interface classes must fulfill. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 stasher |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
A place for remembering things. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 METHODS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 stash |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 unstash |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
See L<Form::Factory::Stash>. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 new_action |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $action = $interface->new_action('Some::Action::Class', \%options); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Given the name of an action class, it initializes the class for use with this interface. The C<%options> are passed to the constructor. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 new_control |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $control = $interface->new_control($name, \%options); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Given the short name for a control and a hash reference of initialization arguments, return a fully initialized control. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 ROLE METHODS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The following methods need to implement the following methods. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 render_control |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
$interface->render_control($control, %options); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This method is used to render the control in the current form. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 consume_control |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$interface->consume_control($control, %options); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This method is used to consume the values input for a current form. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 CONTROLS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Here's a list of controls and the classes they represent: |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item button |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L<Form::Factory::Control::Button> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item checkbox |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L<Form::Factory::Control::Checkbox> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item full_text |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L<Form::Factory::Control::FullText> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item password |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L<Form::Factory::Control::Password> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item select_many |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L<Form::Factory::Control::SelectMany> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item select_one |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L<Form::Factory::Control::SelectOne> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item text |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L<Form::Factory::Control::Text> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item value |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L<Form::Factory::Control::Value> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=back |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 SEE ALSO |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L<Form::Factory::Action>, L<Form::Factory::Control>, L<Form::Factory::Stasher> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHOR |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp <hanenkamp@cpan.org> |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Qubling Software LLC. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
180
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |