« blib/lib/Devel/callcount.pm
↑ Summary
blib/lib/UR/BoolExpr/Template/PropertyComparison/NotEquals.pm »
| 1 | package UR::BoolExpr::Template::PropertyComparison::Equals; | ||
| 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 | no warnings 'uninitialized'; | ||
| 16 | if (@property_values == 0) { | ||
| 17 | return ($comparison_value eq '' ? 1 : ''); | ||
| 18 | } | ||
| 19 | |||
| 20 | no warnings 'numeric'; | ||
| 21 | my $cv_is_number = Scalar::Util::looks_like_number($comparison_value); | ||
| 22 | |||
| 23 | foreach my $property_value ( @property_values ) { | ||
| 24 | my $pv_is_number = Scalar::Util::looks_like_number($property_value); | ||
| 25 | if ($pv_is_number and $cv_is_number) { | ||
| 26 | return 1 if $property_value == $comparison_value; | ||
| 27 | } else { | ||
| 28 | return 1 if $property_value eq $comparison_value; | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | return ''; | ||
| 33 | } | ||
| 34 | |||
| 35 | |||
| 36 | 1; | ||
| 37 | |||
| 38 | =pod | ||
| 39 | |||
| 40 | =head1 NAME | ||
| 41 | |||
| 42 | UR::BoolExpr::Template::PropertyComparison::Equals - perform a strictly equals test | ||
| 43 | |||
| 44 | =head1 DESCRIPTION | ||
| 45 | |||
| 46 | If the property returns multiple values, this comparison returns true if any of the values are equal to the comparison value | ||
| 47 | |||
| 48 | =cut |