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

2015-08-10 Thread Marcos Barbeitos
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

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

2015-08-10 Thread Kent Fredric
On 11 August 2015 at 07:02, Marcos Barbeitos msbarbei...@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

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

2015-08-09 Thread Karen Etheridge
On Sat, Aug 8, 2015 at 1:18 PM, Marcos Barbeitos msbarbei...@gmail.com 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

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

2015-08-09 Thread Karen Etheridge
On Thu, Aug 6, 2015 at 4:04 PM, Marcos Barbeitos msbarbei...@gmail.com wrote: around 'sequence' = sub { my $orig = shift; my $self = shift; my $sequence = uc shift; # Do lots of things with $sequence and then return $self-$orig( $sequence );

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

2015-08-09 Thread John Macdonald
in this message may not be that of the organization. From: Chris Prather [perig...@prather.org] Sent: August 7, 2015 12:27 PM To: Marcos Barbeitos Cc: moose@perl.org Subject: Re: 'around' method modifier does not seem to work So you'll need to provide a reduced

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

2015-08-08 Thread Marcos Barbeitos
Howdy, everybody, thank you so very much for your help. Ben was indeed correct; if I do: around 'sequence' = sub { my $orig = shift; my $self = shift; if ( @_ == 1 ) { my $sequence = _get_parsed_sequence( shift ); return $self-$orig( $sequence ); } else {

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

2015-08-08 Thread Buddy Burden
Marcos, around 'sequence' = sub { my $orig = shift; my $self = shift; if ( @_ == 1 ) { my $sequence = _get_parsed_sequence( shift ); return $self-$orig( $sequence ); } else { return $self-{sequence}; } }; I get it to work. Not a very

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

2015-08-07 Thread Chris Prather
So you'll need to provide a reduced example that demonstrates the behavior your showing. When I tried to reproduce (with the script below) the attribute was being set just fine. #!/usr/bin/env perl use 5.12.1; use warnings; {     package AroundTest;     use Moose;     has foo

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

2015-08-07 Thread Ben Tilly
Change your example to say $at-foo instead of $at-dump to see the bug. Add a check in the around to only try to set foo if @_ actually had 3 elements. Then the bug should go away. I suggest that the documentation add a comment like this: # Return the existing value if we are not trying

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

2015-08-07 Thread Chris Prather
If you check the part he quoted in the original email, that is in there. Obviously three of us missed it so maybe it could be highlighted better. -Chris On Fri, Aug 7, 2015 at 2:28 PM, Ben Tilly bti...@gmail.com wrote: Change your example to say $at-foo instead of $at-dump to see the bug.

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

2015-08-07 Thread Kent Fredric
On 8 August 2015 at 09:09, Chris Prather perig...@prather.org wrote: If you check the part he quoted in the original email, that is in there. Obviously three of us missed it so maybe it could be highlighted better. I think there's confusion stemming from there being *two* methods being

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

2015-08-06 Thread Ben Tilly
Stupid guess. You set the attribute successfully then unset it when you fetch it because you dropped the test for @_ that tells you not to set it then. On Thursday, August 6, 2015, Marcos Barbeitos msbarbei...@gmail.com wrote: Howdy, I looked up the behavior of the modifier 'around' in

'around' method modifier does not seem to work

2015-08-06 Thread Marcos Barbeitos
Howdy, I looked up the behavior of the modifier 'around' in http://search.cpan.org/~ether/Moose-2.1600/lib/Moose/Manual/MethodModifiers.pod#Around_modifiers, and the code snipet is: around 'size' = sub { my $orig = shift; my $self = shift; return $self-$orig()