The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

SYNOPSIS

    my $r = GSC::Clone->define_boolexpr(
        "status" => "active",
        "chromosome" => [2,4,7],
        "clone_name like" => "Foo%",
        "clone_size between" => [100000,200000],
    );
    
    my $o = GSC::Clone->create(
        status => "active", 
        chromosome => 4, 
        clone_name => "FooBar",
        clone_size => 100500
    );    
        
    $r->specifies_value_for_property_name("chromosome") # true
    
    $r->specified_value_for_property_name("chromosome") # 4
        
    $r->evaluate($o); # true
    
    $o->chromosome(11);
    $r->evaluate($o); # false
    
    

DESCRIPTION

Rule objects are used internally by the UR API to define data sets. They have a 1:1 correspondence within the WHERE clause in an SQL statement.

The entire rule description is the identity of the rule. They are not created, just gotten from the infinite set of all possible rules using the resolve_normalized_rule_for_class_and_params() class method (flyweight constructor.)

REFLECTION

The data used to create the rule can be re-extracted:

    my $c = $r->subject_class_name;
    # $c eq "GSC::Clone"

    my @p = $r->params_list;
    # @p = four items
    
    my %p = $r->params_list;
    # %p = two key value pairs

SUBCLASSES

 The ::Rule class is abstract, but the primary constructor (resolve_normalized_rule_for_class_and_params),
 automatically returns rules of the correct subclass for the specified parameters.  
 
 Currently it always returns a ::Rule::And object, which is the composite of all key-value pairs passed-in.
::Rule::And
 Rules of this type contain a list of other rules, ALL of which must be true for the given rule to be true.
 Inherits from the intermediate class ::Rule::Composite.
 
::Rule::Or
 Rules of this type contain a list of other rules, ANY of which must be true for the given rule to be true.
 Inherits from the intermediate class ::Rule::Composite.
::Rule::PropertyComparison
 Rules of this type compare a single property on the subject, using a specific comparison operator,
 against a specific value (or value set for certain operators).  This is the low-level non-composite rule.

INTERNAL STRUCTURE

A rule has an "id", which completely describes the rule in stringified form, and a method called evaluate($o) which tests the rule on a given object.

The id is composed of two parts: - A template_id. - A value_id.

Nearly all real work delegates to the template to avoid duplication of cached details.

The template_id embeds several other properties, for which the rule delegates to it: - subject_class_name, objects of which the rule can be applied-to - subclass_name, the subclass of rule (property comparison, and, or "or") - the body of the rule either key-op-val, or a list of other rules

For example, the rule GSC::Clone name=x,chromosome>y: - the template_id embeds: subject_class_name = GSC::Clone subclass_name = UR::BoolExpr::And and the key-op pairs in sorted order: "chromosome>,name=" - the value_id embeds the x,y values in a special format

PROPERTIES

GENERAL METHODS

EXAMPLES

my $bool = $x->evaluate($obj);

my $t = GSC::Clone->get_rule_template_for_params( "status =", "chromosome []", "clone_name like", "clone_size between" );

my @results = $t->get_matching_objects( "active", [2,4,7], "Foo%", [100000,200000] );

my $r = $t->get_rule($v1,$v2,$v3);

my $t = $r->get_rule_template;

my @results = $t->get_matching_objects($v1,$v2,$v3); my @results = $r->get_matching_objects();

@r = $r->get_underlying_rules(); for (@r) { print $r->evaluate($c1); }

my $rt = $r->get_rule_template(); my @rt = $rt->get_underlying_rule_templates();

$r = $rt->get_rule_for_values(@v);

NAME

UR::BoolExpr - a boolean expression functional on any UR::Object of a given class

SEE ALSO

UR(3), UR::Object(3), UR::Object::Set(3)

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 825:

'=item' outside of any '=over'

Around line 840:

You forgot a '=back' before '=head1'