| 1 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Constraint::Set; | ||||||||||||||||||||||||||||
| 4 | 4 | $HTML::FormFu::Constraint::Set::VERSION = '2.06'; | |||||||||||||||||||||||||||
| 5 | # ABSTRACT: Set of Values Constraint | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | extends 'HTML::FormFu::Constraint'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Clone (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | has set => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub constrain_value { | ||||||||||||||||||||||||||||
| 16 | 11 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
constrain_value: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 11 | ▶ | return 1 if !defined $value || $value eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $value or $value eq ""
MC/DC50%1/2
not defined $value or $value eq ""
not defined $value
$value eq ""
Truth table66%2/3
not(A) or B
A= not defined $valueB= $value eq ""
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 9 | my $set = $self->set; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 9 | my %set = map { $_ => 1 } @$set; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 9 | return exists $set{$value}; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub clone { | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | my $clone = $self->SUPER::clone(@_); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ( $self->set ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | $clone->set( Clone::clone( $self->set ) ); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | return $clone; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 4 | 1; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =pod | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head1 NAME | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | HTML::FormFu::Constraint::Set - Set of Values Constraint | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =head1 VERSION | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | version 2.06 | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | type: Set | ||||||||||||||||||||||||||||
| 60 | set: [yes, no] | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | The input value must be in the specified set of values. | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =head1 METHODS | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head2 set | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Arguments: \@allowed_values | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint> | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | L<HTML::FormFu> | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | Carl Franks C<cfranks@cpan.org> | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | This library is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 85 | the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 96 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =cut | ||||||||||||||||||||||||||||