line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVG::Estimate::Role::ArgsWithUnits; |
2
|
|
|
|
|
|
|
$SVG::Estimate::Role::ArgsWithUnits::VERSION = '1.0107'; |
3
|
9
|
|
|
9
|
|
2862
|
use strict; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
208
|
|
4
|
9
|
|
|
9
|
|
39
|
use Moo::Role; |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
41
|
|
5
|
9
|
|
|
9
|
|
1731
|
use Ouch; |
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
1455
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
SVG::Estimate::Role::ArgsWithUnits - Validate a list of arguments that could contain units |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
version 1.0107 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 METHODS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 BUILDARGS ( ) |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Validate the set of args from the class's C method to make sure they don't have units |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
around BUILDARGS => sub { |
24
|
|
|
|
|
|
|
my $orig = shift; |
25
|
|
|
|
|
|
|
my $class = shift; |
26
|
|
|
|
|
|
|
my @args = @_; |
27
|
|
|
|
|
|
|
my $args = @args % 2 ? $args[0] : { @args }; |
28
|
|
|
|
|
|
|
foreach my $param ($class->args_with_units) { |
29
|
|
|
|
|
|
|
if ($args->{$param} =~ /\d\D+$/) { |
30
|
|
|
|
|
|
|
ouch 'units detected', "$param is not allowed to have units", $args->{$param}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
##Validate before the arguments are used |
34
|
|
|
|
|
|
|
return $class->$orig($args); |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |