UR::Ob...erator(3pm)
π NAME π
UR::Object::Iterator β the API for iterating through objects that match a rule, bestie. That's it, that's the whole job. π¦
Oh and hey, quick vibe check before we start: this page lives in the User Contributed Perl Documentation corner of your system, and the module file is styled UR::Ob...erator(3pm) because apparently even manpages gotta abbreviate for the girlies. π
β¨ SYNOPSIS β¨
Okay so here's the whole point, in code, no yapping:
my $rule = UR::BoolExpr->resolve('Some::Class', foo => 1);
my $iter = UR::Object::Iterator->create_for_filter_rule($rule);
while (my $obj = $iter->next()) {
print "Got an object: ",$obj->id,"\n";
}
# Equivalent
my $iter2 = Some::Class->create_iterator(foo => 1);
while (my $obj = $iter2->next()) {
print "Got an object: ",$obj->id,"\n";
}
Both of those do literally the same thing, just entering the party through different doors. πͺβ¨
πΈ DESCRIPTION πΈ
So like, get() β which is implemented over in UR::Object β is the usual way to retrieve a set of objects matching particular properties. Totally valid, no shade.
But when the result set of data is large? Oof. It's often more efficient to use an iterator to access the data instead of getting it all in one giant list and holding the whole thing in your arms like a chaotic pile of laundry. π§Ί
UR::Object implements create_iterator(), which is just a cute little wrapper around create_for_filter_rule(). That's it, that's the whole relationship. π«Ά
And important β UR::Object::Iterator instances are normal Perl object references, not UR-based objects. So they do not live in the Context's object cache, and they obey the normal Perl rules about scoping. They're just, like, regular objects doing their own thing. Main character energy, honestly. π
π CONSTRUCTOR π
create_for_filter_rule
$iter = UR::Object::Iterator->create_for_filter_rule($boolexpr);
Creates an iterator object based on the given BoolExpr (aka the rule). β¨
Under the hood β and this is the tea β it calls get_objects_for_class_and_rule() on the current Context</>, with the $return_closure flag set to true. That's the whole magic trick. πͺ
π¦ Methods inherited from UR::Iterator
nextmappeekremaining
Yeah bestie, you get all four of those for free. Slay. π
π SEE ALSO π
Go read these next, they're all connected, iykyk:
UR::IteratorUR::ObjectUR::Context
fr fr, that's the entire page. Nothing skipped, nothing hidden. π
Okay bye babes β this was perl v5.32.1, dated 2022-01-17, straight outta the UR::Ob...erator(3pm) page. Go iterate on something gorgeous. ππβ
π¦ where this page comes from
- debian bookworm: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms