File Coverage

lib/UR/BoolExpr/Template/PropertyComparison/LessOrEqual.pm
Criterion Covered Total %
statement 16 17 94.1
branch 4 6 66.6
condition 2 3 66.6
subroutine 4 4 100.0
pod n/a
total 26 30 86.6


line stmt bran cond sub pod time code
1              
2             package UR::BoolExpr::Template::PropertyComparison::LessOrEqual;
3              
4 5     5   248 use strict;
  5         7  
  5         155  
5 5     5   22 use warnings;
  5         6  
  5         614  
6             require UR;
7             our $VERSION = "0.46"; # UR $VERSION;
8              
9             UR::Object::Type->define(
10             class_name => __PACKAGE__,
11             is => ['UR::BoolExpr::Template::PropertyComparison'],
12             );
13              
14             sub _compare {
15 42     42   57 my ($class,$comparison_value,@property_value) = @_;
16              
17 42         98 my $cv_is_number = Scalar::Util::looks_like_number($comparison_value);
18              
19 5     5   20 no warnings 'uninitialized';
  5         7  
  5         532  
20 42         53 foreach my $property_value ( @property_value ) {
21 42         55 my $pv_is_number = Scalar::Util::looks_like_number($property_value);
22              
23 42 100 66     129 if ($cv_is_number and $pv_is_number) {
24 30 50       159 return 1 if ( $property_value <= $comparison_value );
25             } else {
26 12 50       68 return 1 if ( $property_value le $comparison_value );
27             }
28             }
29 0           return '';
30             }
31              
32              
33             1;
34              
35             =pod
36              
37             =head1 NAME
38              
39             UR::BoolExpr::Template::PropertyComparison::LessOrEqual - perform a less than or equal test
40              
41             =head1 DESCRIPTION
42              
43             If the property returns multiple values, this comparison returns true if any of the values are
44             less or equal to the comparison value
45              
46             =cut
47