Scott Smith > UR-0.39 > UR::DeletedRef

Download:
UR-0.39.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.39   Source   Latest Release: UR-0.43

NAME ^

UR::DeletedRef - Represents an instance of a no-longer-existent object

SYNOPSIS ^

  my $obj = Some::Class->get(123);
  
  $obj->delete;
  print ref($obj),"\n";  # prints 'UR::DeletedRef'
  $obj->some_method();   # generates an exception through Carp::confess

  $obj->resurrect; 
  print ref($obj),"\n";  # prints 'Some::Class'

DESCRIPTION ^

Object instances become UR::DeletedRefs when some part of the application calls delete() or unload() on them, meaning that they no longer exist in that Context. The extant object reference is turned into a UR::DeletedRef so that if that same reference is used in any capacity later in the program, it will generate an exception through its AUTOLOAD to prevent using it by mistake.

Note that UR::DeletedRef instances are different than Ghost objects. When a UR-based object is deleted through delete(), a new Ghost object reference is created from the data in the old object, and the old object reference is re-blessed as a UR::DeletedRef. Any variables still referencing the original object now hold a reference to this UR::DeletedRef. The Ghost object can be retrieved by issuing a get() against the Ghost class.

Objects unloaded from the Context using unload(), or indirectly by rolling-back a transaction which triggers unload of objects loaded during the transaction, are also turned into UR::DeletedRefs.

You aren't likely to encounter UR::DeletedRefs in normal use. What usually happens is that an object will be deleted with delete() (or unload()), the lexical variable pointing to the DeletedRef will soon go out of scope and the DeletedRef will then be garbage-colelcted.

SEE ALSO ^

UR::Object, UR::Object::Ghost, UR::Context

syntax highlighting: