« blib/lib/UR/BoolExpr/Template/PropertyComparison/GreaterThan.pm
↑ Summary
blib/lib/UR/BoolExpr/Template/PropertyComparison/LessOrEqual.pm »
| 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 |