File Coverage

lib/UR/BoolExpr/Template/PropertyComparison/NotLike.pm
Criterion Covered Total %
statement 18 18 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 24 25 96.0


line stmt bran cond sub pod time code
1              
2             package UR::BoolExpr::Template::PropertyComparison::NotLike;
3              
4 4     4   190 use strict;
  4         8  
  4         115  
5 4     4   13 use warnings;
  4         6  
  4         102  
6 4     4   13 use UR;
  4         4  
  4         23  
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 12     12   15 my ($class,$comparison_value,@property_value) = @_;
16 12         13 my $escape = '\\';
17 12         24 my $regex = $class->
18             comparison_value_and_escape_character_to_regex(
19             $comparison_value,
20             $escape
21             );
22 4     4   15 no warnings 'uninitialized';
  4         5  
  4         354  
23 12         18 foreach my $property_value ( @property_value ) {
24 12 50       39 return '' if ($property_value =~ $regex);
25             }
26 12         56 return 1;
27             }
28              
29             1;
30              
31             =pod
32              
33             =head1 NAME
34              
35             UR::BoolExpr::Template::PropertyComparison::NotLike - perform a negated SQL-ish like test
36              
37             =head1 DESCRIPTION
38              
39             The input test value is assummed to be an SQL 'like' value, where '_'
40             represents a one character wildcard, and '%' means a 0 or more character
41             wildcard. It gets converted to a perl regular expression and used in a
42             negated match against an object's properties
43              
44             If the property returns multiple values, this comparison returns false if
45             any of the values matches the pattern
46              
47             =cut
48