in reply to Re: Re: New scratchpads
in thread New scratchpads
I'm not familiar with the PM code, but in my work application I can mark a field 'defer', in which case normal fetches of the object won't fetch that field, and the accessor knows to do the extra fetch for deferred fields if the hash key doesn't exist. It looks something like this:
if ($field->defer) { no strict 'refs'; *{"${class}::$method"} = sub { use strict 'refs'; my $self = shift; $self->load_deferred if !$self->{_blank} && !exists($self->{$met +hod}); return $self->{$method}; }; }
That is to say: we need to load deferred fields if this is a real object (!$self->{_blank}) and the field hasn't been loaded (!exists($self->{$method})).
I don't know how applicable this approach might be to PM, but it works fine for me. :)
Hugo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: New scratchpads
by demerphq (Chancellor) on Jun 08, 2004 at 17:12 UTC |