CalculatedValue/Validatable.pm

filter: Statementstmt 91.6% 22 / 24 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 87.5% 28 / 32 CC 3 SCAR 7.9
CC
3
Cov
85%
_validate_all_sub_adjustments
3.8
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« CalculatedValue.pm ↑ Summary
1 package Math::Util::CalculatedValue::Validatable;
2  
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use MooseX::NonMoose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 extends 'Math::Util::CalculatedValue';
7 2 with 'MooseX::Role::Validatable';
8  
9 =head1 NAME
10  
11 Math::Util::CalculatedValue::Validatable - math adjustment, which can containe another adjustments with validation
12  
13 =head1 DESCRIPTION
14  
15 Represents an adjustment to a value (which can contain additional adjustments) with validation.
16  
17 =cut
18  
19 2 our $VERSION = '0.07'; ## VERSION
20  
21 =head1 SYNOPSIS
22  
23 my $tid = Math::Util::CalculatedValue::Validatable->new({
24 name => 'time_in_days',
25 description => 'Duration in days',
26 set_by => 'Contract',
27 base_amount => 0,
28 });
29  
30 my $tiy = Math::Util::CalculatedValue::Validatable->new({
31 name => 'time_in_years',
32 description => 'Duration in years',
33 set_by => 'Contract',
34 base_amount => 1,
35 });
36  
37 my $dpy = Math::Util::CalculatedValue::Validatable->new({
38 name => 'days_per_year',
39 description => 'days in a year',
40 set_by => 'Contract',
41 base_amount => 365,
42 });
43  
44 $tid->include_adjustment('reset', $tiy);
45 $tid->include_adjustment('multiply', $dpy);
46  
47 print $tid->amount;
48  
49  
50 =head2 BUILD
51  
52 Bulder args to add validation method
53  
54 =cut
55  
56 1 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod documented
57 1 my $self = shift;
58 1 $self->{validation_methods} = [qw(_validate_all_sub_adjustments)];
59 1 return;
60 }
61  
62 1 ▶sub _validate_all_sub_adjustments {
Subroutine _validate_all_sub_adjustments: called CC=3 SCAR=13.3
63 1 my $self = shift;
64  
65 1 my @errors;
66 0 foreach my $cv (map { $_->[1] } @{$self->adjustments}) {
67 0 ▶ push @errors, $cv->all_errors unless ($cv->confirm_validity);
Branch: 1 branch
BranchTrueFalseTotal
unless $cv->confirm_validity 0 0 0
68 }
69  
70 1 return @errors;
71 }
72  
73 =head1 AUTHOR
74  
75 binary.com, C<< <rakesh at binary.com> >>
76  
77 =head1 BUGS
78  
79 Please report any bugs or feature requests to C<bug-math-util-calculatedvalue at rt.cpan.org>, or through
80 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math-Util-CalculatedValue>. I will be notified, and then you'll
81 automatically be notified of progress on your bug as I make changes.
82  
83  
84 =head1 SUPPORT
85  
86 You can find documentation for this module with the perldoc command.
87  
88 perldoc Math::Util::CalculatedValue
89  
90  
91 You can also look for information at:
92  
93 =over 4
94  
95 =item * RT: CPAN's request tracker (report bugs here)
96  
97 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Math-Util-CalculatedValue>
98  
99 =item * AnnoCPAN: Annotated CPAN documentation
100  
101 L<http://annocpan.org/dist/Math-Util-CalculatedValue>
102  
103 =item * CPAN Ratings
104  
105 L<http://cpanratings.perl.org/d/Math-Util-CalculatedValue>
106  
107 =item * Search CPAN
108  
109 L<http://search.cpan.org/dist/Math-Util-CalculatedValue/>
110  
111 =back
112  
113  
114 =head1 ACKNOWLEDGEMENTS
115  
116 =cut
117  
118 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
119  
120 2 __PACKAGE__->meta->make_immutable;
121  
122 2 1; # End of Math::Util::CalculatedValue::Validatable
« CalculatedValue.pm ↑ Summary