Class-Persist
view release on metacpan or search on metacpan
lib/Class/Persist/Proxy.pm view on Meta::CPAN
126127128129130131132133134135136137138139140141142143144145146
if
(
my
$object
=
$tracker
->object) {
$self
->_duplicate_from(
$object
);
bless
$self
=>
ref
(
$object
);
return
$self
;
}
}
return
$self
->record(
'Class::Persist::Error::DB::NotFound'
,
"Could not load $class for $self"
, 1)
}
$self
->_duplicate_from(
$obj
);
bless
$self
=>
$class
;
}
=head2 proxy( $obj )
Replace object by proxy
=cut
sub
proxy {
lib/Class/Persist/Proxy.pm view on Meta::CPAN
151152153154155156157158159160161162163164165166167168169170171
$obj
->isa(
'Class::Persist'
) or Class::Persist::Error::InvalidParameters->throw(
text
=>
"object to proxy should be a Class::Persist"
);
$class
->loadModule(
ref
$obj
) or
return
;
my
$self
=
$class
->new();
$self
->class(
ref
$obj
);
if
(
$owner
) {
$self
->owner(
$owner
);
}
$self
->real_id(
$obj
->oid );
$obj
->_duplicate_from(
$self
);
bless
$obj
=>
$class
;
}
sub
AUTOLOAD {
my
$self
=
shift
;
$self
=
$self
->load() or
return
;
# die "Can't find in DB from ".(caller)[0]." line ".(caller)[2];
my
$meth
=
substr
(
$AUTOLOAD
,
rindex
(
$AUTOLOAD
,
':'
) + 1);
my
$can
=
$self
->can(
$meth
) or EO::Error::Method::NotFound->throw(
text
=>
"Method $meth unknownin class "
.
ref
(
$self
));
$can
->(
$self
,
@_
);
}
( run in 0.261 second using v1.01-cache-2.11-cpan-05444aca049 )