develooper Front page | perl.moose | Postings from August 2015

Re: 'around' method modifier does not seem to work

Thread Previous | Thread Next
From:
Kent Fredric
Date:
August 11, 2015 02:15
Subject:
Re: 'around' method modifier does not seem to work
Message ID:
CAATnKFB-Xzw2XBZ4kmaEDgpiAyLjBC+73=0gaH+LVDtOMHgNnw@mail.gmail.com
On 11 August 2015 at 07:02, Marcos Barbeitos <msbarbeitos@gmail.com> wrote:
> Thanks for the tip, it works as expected, except when I pass the attribute
> to the constructor.  In that case, I get the original sequence, and not its
> parsed version.
>
> I added a print statement to the 'around' modifier so that I could keep
> track of how many times 'around' was called.
>
> I noticed that the modifier was called when you set the attribute and
> everytime you fetch it, but not when it is passed to the constructor. As
> Buddy noticed, maybe it really shouldn't be.
>
> No biggie, though, I found out that I may actually have to re-structure the
> code and I'll probably have no need for the modifier after I do.


That's because the constructor doesn't set the attributes by passing
them to $object->method($value), but instead does some magic in
$object->meta-> ...

What it seems like you really want is some sort of Type Coercion, so
that when data of a given type is passed to the constructor, the type
coercion unpacks it into a form suitable.


-- 
Kent

KENTNL - https://metacpan.org/author/KENTNL

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About