UR::Ob...::Ghost(3pm)
π UR::Object::Ghost β the deleted-but-not-yet-committed era π
okay bestie, so this is a page from the User Contributed Perl Documentation, and it's about UR::Object::Ghost β the abstract class that represents deleted objects that haven't been committed yet. spooky name, very on brand, let's get into it π¦
β¨ NAME β¨
UR::Object::Ghost β Abstract class for representing deleted objects not yet committed.
like, it's giving "the ghost of objects past", no cap π»
π SYNOPSIS π
okay so here's the whole vibe in code, keep it exactly like this bestie:
my $obj = Some::Class->get(1234);
$obj->some_method();
$obj->delete(); # $obj is now a UR::DeletedRef
$ghost = Some::Class::Ghost->get(1234);
$ghost->some_method; # Works
so you get your object, you call a method on it, you delete() it β boom, $obj is now a UR::DeletedRef π β and then you can go grab the ghost version from Some::Class::Ghost and the methods still work. iconic. she persists even in the afterlife. π
πΈ DESCRIPTION πΈ
okay so let me explain the whole situation, because Ghost objects are literally just a bookkeeping entity. they exist to track objects that:
- got loaded from an external data source
- got deleted inside the application
- haven't been committed yet
and lowkey that implies the object still exists in the external data source β the delete hasn't actually landed anywhere yet, it's just vibing in limbo. π
here's the part that matters: when the Context is committed, the existence of Ghost objects triggers commands to the external data sources to also delete the object(s). so the ghost is basically the little reminder note that says "hey, this one's gotta go."
and it goes the other way too β¨ when objects are brought into the Context by querying a data source, they get compared against any ghosts that may already exist. if they match, those objects are not re-loaded and they are not returned to the user from a call to get(). so no zombie resurrections unless you ask for them.
if the user wants to get Ghost objects, they must call get() explicitly on the Ghost class. there's no sneaky way around it, bestie. be intentional. π
also, every class in the system has an associated Ghost class, and the name is formed by tacking '::Ghost' onto the name of the regular class. cute little naming convention. and listen β Ghost classes do not have ghosts themselves. ghosts don't have ghosts. that's just the rules. π«Ά
now, the instantiation lore: instances of Ghosts are not instantiated with create() directly. they are created as a consequence of deleting a regular object instance. you don't make a ghost, you earn a ghost. π
and a Ghost can be turned back into a "live" object by re-creating it, or by rolling back the transaction it was deleted in. resurrection arc, main character energy, we love to see it π
β οΈ DEPRECATED β οΈ
okay so this is the part where I have to be real with you:
Applications will not, and should not, normally interact with Ghosts. π«
The whole Ghost system is scheduled for elimination as we refactor the Context and software transaction framework. so yeah β it's deprecated, it's on the way out, don't build your whole personality around it. ππ
π SEE ALSO π
UR::ObjectUR::Object::Type
go read those, bestie, they're the supporting cast π
and that's the whole page fr fr β¨ this was UR::Ob...::Ghost(3pm) β yes the title got truncated, that's just how it renders, we don't talk about it π β shipped as part of perl v5.32.1, dated 2022-01-17. stay spooky, stay committed (or don't, that's literally the whole point) π
ππ
π¦ 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