JavaScript/Constraint/AllOrNone.pm

filter: Statementstmt 57.8% 11 / 19 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 57.6% 15 / 26 CC 2 SCAR 11.0
CC
2
Cov
52%
emit_javascript
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« JavaScript/Constraint/String.pm ↑ Summary JavaScript/Constraint/All.pm »
1 package HTML::Widget::JavaScript::Constraint::AllOrNone;
2
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 2 ▶use base 'HTML::Widget::Constraint::AllOrNone';
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 =head1 NAME
9
10 HTML::Widget::JavaScript::Constraint::AllOrNone - JavaScript AllOrNone Constraint
11
12 =head1 VERSION
13
14 Version 0.02
15
16 =cut
17
18 2 our $VERSION = '0.02';
19
20 =head1 SYNOPSIS
21
22 JavaScript AllOrNone Constraint.
23
24 =head1 METHODS
25
26 See L<HTML::Widget::Constraint::AllOrNone>.
27
28 =head2 $self->emit_javascript($var_name)
29
30 Emits this constraint's JavaScript validation code.
31
32 =cut
33
34 0 ▶sub emit_javascript {
Subroutine emit_javascript: not called CC=2 SCAR=17.9
Pod documented
35 0 my ($self, $var_name) = @_;
36
37 0 my @js_constraints;
38
39 0 ▶ my $not = $self->not ? '' : '!';
Branch: 1 branch
BranchTrueFalseTotal
$self->not ? : 0 0 0
40
41 return
42 "($not((" .
43 0 join(' && ', map {"${var_name}.$_.value != ''"} @{$self->names}) .
44 ') || (' .
45 0 join(' && ', map {"${var_name}.$_.value == ''"} @{$self->names})
46 . ')))';
47 }
48
49 =head1 AUTHOR
50
51 Nilson Santos Figueiredo Júnior, C<< <nilsonsfj at cpan.org> >>
52
53 =head1 BUGS
54
55 Please report any bugs or feature requests directly to the author.
56 If you ask nicely it will probably get fixed or implemented.
57
58 =head1 COPYRIGHT & LICENSE
59
60 Copyright 2006, 2009 Nilson Santos Figueiredo Júnior, all rights reserved.
61
62 This program is free software; you can redistribute it and/or modify it
63 under the same terms as Perl itself.
64
65 =cut
66
67 2 1; # End of HTML::Widget::JavaScript::Constraint
« JavaScript/Constraint/String.pm ↑ Summary JavaScript/Constraint/All.pm »