Re: 'around' method modifier does not seem to work
[email protected] (Marcos Barbeitos) Mon, 10 Aug 2015 16:02:54 -0300
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <CA+gEHsUbUSz+b2TeKqM8-JPu=+jFkE+85SiaUrCj2AhZg7qYsg@mail.gmail.com> |
--089e0102f84a0ecd2b051cf9a2e6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Karen and everybody else, 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. Again, many thanks to all! On Sat, Aug 8, 2015 at 8:52 PM, Karen Etheridge <[email protected]> wrote: > > On Sat, Aug 8, 2015 at 1:18 PM, Marcos Barbeitos <[email protected]= > > wrote: > > > I get it to work. Not a very elegant solution, for I must access > the attribute directly instead of using an accessor. > > No, instead of > > return $self->{sequence}; > you should do > return $self->$orig(); > to use the proper reader mechanism. > > > One issue still remains though, if I pass the argument to the > constructor: > > my $collection =3D DCSE::Collection->new > > ( > > id =3D> 'test' > > , sequence =3D> $sequence > > , helix =3D> $dcse->helix > > ); > > > > I believe that 'around' is not called, for I get the unparsed > argument when I fetch the attribute. > > This should be fixed when you fix the code path for the reader as above. > > --=20 Marcos S. Barbeitos Departamento de Zoologia - Sala 360 Setor de Ci=C3=AAncias Biol=C3=B3gicas Universidade Federal do Paran=C3=A1 Caixa Postal 19020 Curitiba, PR 81531-990 Brazil Phone: (55 41) 3361-1634 --089e0102f84a0ecd2b051cf9a2e6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hi Karen and everybody else,<div><br></div><div>Thanks for= the tip, it works as expected, except when I pass the attribute to the con= structor.=C2=A0 In that case, I get the original sequence, and not its pars= ed version.</div><div><br></div><div>I added a print statement to the '= around' modifier so that I could keep track of how many times 'arou= nd' was called.</div><div><br></div><div>I noticed that the modifier wa= s called when you set the attribute and everytime you fetch it, but not whe= n it is passed to the constructor. As Buddy noticed, maybe it really should= n't be.</div><div><br></div><div>No biggie, though, I found out that I = may actually have to re-structure the code and I'll probably have no ne= ed for the modifier after I do.</div><div><br></div><div>Again, many thanks= to all!</div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quot= e">On Sat, Aug 8, 2015 at 8:52 PM, Karen Etheridge <span dir=3D"ltr"><<a= href=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>><= /span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8= ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span clas= s=3D"">> On Sat, Aug 8, 2015 at 1:18 PM, Marcos Barbeitos <<a href=3D= "mailto:[email protected]" target=3D"_blank">[email protected]</a>&= gt; wrote:<br><br>>=C2=A0=C2=A0=C2=A0=C2=A0 I get it to work.=C2=A0 Not = a very elegant solution, for I must access the attribute directly instead o= f using an accessor. <br><br></span>No, instead of<br>>=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return $self->= {sequence};=C2=A0=C2=A0=C2=A0 =C2=A0<br>you should do<br>=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return $self-&= gt;$orig();<br>to use the proper reader mechanism.<span class=3D""><br><br>= >=C2=A0=C2=A0=C2=A0=C2=A0 One issue still remains though, if I pass the = argument to the constructor:<br>>=C2=A0=C2=A0=C2=A0=C2=A0 my $collection= =3D DCSE::Collection->new<br>>=C2=A0=C2=A0=C2=A0=C2=A0 (<br>>=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 id =3D> 'test'<br>>= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 , sequence =3D> $sequence<br>>=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 , helix =3D> $dcse->helix<br>>=C2=A0=C2= =A0=C2=A0=C2=A0 );<br>> <br>>=C2=A0=C2=A0=C2=A0=C2=A0 I believe that = 'around' is not called, for I get the unparsed argument when I fetc= h the attribute. <br><br></span>This should be fixed when you fix the code = path for the reader as above.<br><br></div> </blockquote></div><br><br clear=3D"all"><div><br></div>-- <br><div class= =3D"gmail_signature"><div dir=3D"ltr">Marcos S. Barbeitos<br><br>Departamen= to de Zoologia - Sala 360<br>Setor de Ci=C3=AAncias Biol=C3=B3gicas<br>Univ= ersidade Federal do Paran=C3=A1<br>Caixa Postal 19020<br>Curitiba, PR 81531= -990<br>Brazil<br><br>Phone: (55 41) 3361-1634</div></div> </div> --089e0102f84a0ecd2b051cf9a2e6--