NAME
Class::Persist::Proxy - Proxy for an object not loaded yet
SYNOPSIS
use Class::Persist::Proxy;
$proxy = Class::Persist::Proxy->new( class => "Class", oid => "oid" );
$real = $proxy->load();
DESCRIPTION
Framework to replace objects in the DB by Proxy objects. This allows delayed loading of objects. A proxy acts as the real object itself, it should be transparent. When a method is called on the proxy, the real object is loaded in place of the proxy.
INHERITANCE
Class::Persist::Base
METHODS
new( class => "class", real_id => "oid" )
Creates a proxy for the specified class and oid. These two must be passed to the constructor or an error will be thrown.
oid()
Tries hard to return the oid of the object proxied, if it fails, returns the proxy oid.
real_id()
returns the oid of the thing we're proxying
class()
returns the class of the thing we're proxying.
dbh
returns a DBH object. We use the dbh that our class uses, so dbh must work as a class method on the proxied class.
load()
Replace (in-place) the proxy by its target object
proxy( $obj )
Replace an object in-place by a proxy. This method doesn't store the object - do that first if you want to keep changes.
my $myobj = Object->load( $oid ); # load the object
Class::Persist::Proxy->proxy( $myobj ); # and proxy it
SEE ALSO
Class::Persist
AUTHOR
Fotango