line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Util::CalculatedValue::Validatable; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
13983
|
use Moose; |
|
1
|
|
|
|
|
292284
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5101
|
use MooseX::NonMoose; |
|
1
|
|
|
|
|
688
|
|
|
1
|
|
|
|
|
3
|
|
6
|
|
|
|
|
|
|
extends 'Math::Util::CalculatedValue'; |
7
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub BUILD { |
57
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
58
|
1
|
|
|
|
|
2
|
$self->{validation_methods} = [qw(_validate_all_sub_adjustments)]; |
59
|
1
|
|
|
|
|
27
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _validate_all_sub_adjustments { |
63
|
1
|
|
|
1
|
|
1175
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
2
|
my @errors; |
66
|
1
|
|
|
|
|
1
|
foreach my $cv (map { $_->[1] } @{$self->adjustments}) { |
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
10
|
|
67
|
0
|
0
|
|
|
|
0
|
push @errors, $cv->all_errors unless ($cv->confirm_validity); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
5
|
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
|
1
|
|
|
1
|
|
42677
|
no Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; # End of Math::Util::CalculatedValue::Validatable |