line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Factory::Control::Choice; |
2
|
|
|
|
|
|
|
$Form::Factory::Control::Choice::VERSION = '0.022'; |
3
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Helper class for tracking choices |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has label => ( |
9
|
|
|
|
|
|
|
is => 'ro', |
10
|
|
|
|
|
|
|
isa => 'Str', |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has value => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => 'Str', |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub BUILDARGS { |
21
|
13
|
|
|
13
|
1
|
15
|
my $class = shift; |
22
|
13
|
|
|
|
|
8
|
my %args; |
23
|
|
|
|
|
|
|
|
24
|
13
|
50
|
33
|
|
|
62
|
if (@_ == 1 and ref $_[0]) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
%args = %{ $_[0] }; |
|
0
|
|
|
|
|
0
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif (@_ == 1) { |
28
|
13
|
|
|
|
|
23
|
$args{value} = $_[0]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif (@_ == 2) { |
31
|
0
|
|
|
|
|
0
|
$args{value} = $_[0]; |
32
|
0
|
|
|
|
|
0
|
$args{label} = $_[1]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
0
|
|
|
|
|
0
|
%args = @_; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
13
|
50
|
|
|
|
32
|
$args{label} = $args{value} unless defined $args{label}; |
39
|
|
|
|
|
|
|
|
40
|
13
|
|
|
|
|
56
|
return $class->SUPER::BUILDARGS(%args); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=pod |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=encoding UTF-8 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Form::Factory::Control::Choice - Helper class for tracking choices |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 VERSION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
version 0.022 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SYNOPSIS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $foo = Form::Factory::Control::Choice->new('foo'); |
62
|
|
|
|
|
|
|
my $bar = Form::Factory::Control::Choice->new('bar' => 'Bar'); |
63
|
|
|
|
|
|
|
my $baz = Form::Factory::Control::Choice->new( |
64
|
|
|
|
|
|
|
label => 'Baz', |
65
|
|
|
|
|
|
|
value => 'baz', |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
my $qux = Form::Factory::Control::Choice->new({ |
68
|
|
|
|
|
|
|
label => 'Qux', |
69
|
|
|
|
|
|
|
value => 'qux', |
70
|
|
|
|
|
|
|
}); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
These objects represent a single choice for a list or popup box. Each choice has a label and a value. The constructor is flexible to allow the following uses: |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $choice = Form::Factory::Control::Choice->new($value) # $label = $value |
77
|
|
|
|
|
|
|
my $choice = Form::Factory::Control::Choice->new($value => $label); |
78
|
|
|
|
|
|
|
my $choice = Form::Factory::Control::Choice->new( |
79
|
|
|
|
|
|
|
label => $label, |
80
|
|
|
|
|
|
|
value => $value, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
my $choice = Form::Factory::Control::Choice->new({ |
83
|
|
|
|
|
|
|
label => $label, |
84
|
|
|
|
|
|
|
value => $value, |
85
|
|
|
|
|
|
|
}); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
If C<$value> and C<$label> are the same, all of those calls are identical. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 label |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The label to give the choice. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 value |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The value of the choice. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp <hanenkamp@cpan.org> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Qubling Software LLC. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
108
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |