blib/lib/UR/BoolExpr/Template/PropertyComparison/Isa.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 34 SCAR 30.0
CC
4
Cov
0%
_compare
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 20.0
1 package UR::BoolExpr::Template::PropertyComparison::Isa;
2 use strict;
3 use warnings;
4 use UR;
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 my ($class,$comparison_value,@property_values) = @_;
14
15 if (ref $comparison_value) {
16 # Reference... maybe an Object?
17 local $@;
18 if (eval { $comparison_value->isa('UR::Object::Type')} ) {
19 # It's a class object. Compare to the Class's class_name
20 $comparison_value = $comparison_value->class_name;
21 } else {
22 # It's an object... test on that object's type
23 $comparison_value = ref($comparison_value);
24 }
25 }
26  
27 foreach my $property_value ( @property_values ) {
28 return 1 if (eval { $property_value->isa($comparison_value) });
29 }
30  
31 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