File Coverage

lib/UR/BoolExpr/Template/PropertyComparison/Isa.pm
Criterion Covered Total %
statement 15 20 75.0
branch 3 6 50.0
condition n/a
subroutine 4 4 100.0
pod n/a
total 22 30 73.3


line stmt bran cond sub pod time code
1             package UR::BoolExpr::Template::PropertyComparison::Isa;
2 1     1   61 use strict;
  1         1  
  1         29  
3 1     1   4 use warnings;
  1         2  
  1         25  
4 1     1   3 use UR;
  1         1  
  1         6  
5             our $VERSION = "0.46"; # UR $VERSION;
6              
7             UR::Object::Type->define(
8             class_name => __PACKAGE__,
9             is => ['UR::BoolExpr::Template::PropertyComparison'],
10             );
11              
12             sub _compare {
13 42     42   52 my ($class,$comparison_value,@property_values) = @_;
14            
15 42 50       65 if (ref $comparison_value) {
16             # Reference... maybe an Object?
17 0         0 local $@;
18 0 0       0 if (eval { $comparison_value->isa('UR::Object::Type')} ) {
  0         0  
19             # It's a class object. Compare to the Class's class_name
20 0         0 $comparison_value = $comparison_value->class_name;
21             } else {
22             # It's an object... test on that object's type
23 0         0 $comparison_value = ref($comparison_value);
24             }
25             }
26              
27 42         44 foreach my $property_value ( @property_values ) {
28 42 100       40 return 1 if (eval { $property_value->isa($comparison_value) });
  42         400  
29             }
30              
31 6         17 return '';
32             }
33              
34              
35             1;
36              
37             =pod
38              
39             =head1 NAME
40              
41             UR::BoolExpr::Template::PropertyComparison::Isa - Test whether a value is-a subclass of another class
42              
43             =head1 DESCRIPTION
44              
45             If the property returns multiple values, this comparison returns true if any
46             of the values are a subclass of the comparison value
47              
48             =cut