in _process_options you can replace the builder with a default, that wraps the
builder:
my $builder = delete $options{builder};
$options{default} = sub {
my $self = shift;
# do your custom stuff;
$self->$builder;
};
cheers,
mo
Am 27.04.2012 um 17:24 schrieb Maddy, Noel:
> I'm implementing an attribute trait that needs to wrap any existing
> default or builder so it can provide a value to the attribute.
>
> Wrapping a default, either scalar or sub, is easily done in an
> "after _process_options".
>
> Handling a builder isn't quite that easy -- if the builder method is
> defined before the attribute, then it's a simple add_around_method_modifier
> in _process_options.
>
> If the builder method is not yet defined when _process_options is
> running, then it's trickier. I'm thinking that I'll have to stash the desired
> after-builder wrapper method temporarily in the Class metaclass, and then
> after every method is added to the class, check to see if there's a pending
> method wrapper to apply.
>
> This seems a bit hackish -- am I missing something? Is there a better way to
> do this?
>
> Thanks,
> Noel
>
> ________________________________
> CONFIDENTIALITY NOTICE: This email contains information from the sender that
> may be CONFIDENTIAL, LEGALLY PRIVILEGED, PROPRIETARY or otherwise protected
> from disclosure. This email is intended for use only by the person or entity
> to whom it is addressed. If you are not the intended recipient, any use,
> disclosure, copying, distribution, printing, or any action taken in reliance
> on the contents of this email, is strictly prohibited. If you received this
> email in error, please contact the sending party by reply email, delete the
> email from your computer system and shred any paper copies.
>
> Note to Patients: There are a number of risks you should consider before
> using e-mail to communicate with us. See our Privacy Policy and Henry Ford My
> Health at www.henryford.com for more detailed information. If you do not
> believe that our policy gives you the privacy and security protection you
> need, do not send e-mail or Internet communications to us.