Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Newsgroups | perl.moose |
|---|---|
| Path | csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!nntp.perl.org |
| Xref | csiph.com perl.moose:2303 |
| Return-Path | <barefootcoder@gmail.com> |
| Mailing-List | contact moose-help@perl.org; run by ezmlm |
| Delivered-To | mailing list moose@perl.org |
| Received | (qmail 19200 invoked from network); 8 Aug 2015 23:28:08 -0000 |
| Received | from x1.develooper.com (207.171.7.70) by x6.develooper.com with SMTP; 8 Aug 2015 23:28:08 -0000 |
| Received | (qmail 21076 invoked by uid 225); 8 Aug 2015 23:28:08 -0000 |
| Delivered-To | moose@perl.org |
| Received | (qmail 21072 invoked by alias); 8 Aug 2015 23:28:08 -0000 |
| X-Spam-Status | No, hits=-2.7 required=8.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS |
| X-Spam-Check-By | la.mx.develooper.com |
| Received | from mail-oi0-f47.google.com (HELO mail-oi0-f47.google.com) (209.85.218.47) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Sat, 08 Aug 2015 16:28:05 -0700 |
| Received | by oiev193 with SMTP id v193so41674076oie.3 for <moose@perl.org>; Sat, 08 Aug 2015 16:27:54 -0700 (PDT) |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=Rg9fQvry2RbtkgwDwdo3XqqWXgZKVNJu73txYJkO96Y=; b=bDng8KTTErMHvXB23/pntQ2wsMdQO5TI0YlTfZIu0ZCFk2butDc+r+MqX/ECiyVAEh Ltqlod52T03UkShWQuMb/Xp5dPJssWfrMTc3ZZ9hjbUsJnoZZiD8yzeJSzCGo/ZhNJMt oIkgr8v4Otdjv3Cx2A8UYFr6ulf3w8sJoi5iPolBofuT+BPncfP+/4ZWYiMrIlSYYh3x Lo9MpHloCxVQwQs2vU5Wv/faZ7PJbxrrFC27NhNRcvv0UHlhHd9fysRfoKRJ1dZbI3AK Znfabd07D8NU6REcLsww6m8I5mUkKAy/c4mwnnNIqTO1+1bS4cvgd08Tvszam6ogXeys cG7A== |
| X-Received | by 10.202.214.72 with SMTP id n69mr12745224oig.67.1439076473924; Sat, 08 Aug 2015 16:27:53 -0700 (PDT) |
| Received | from ?IPv6:2602:306:3a25:b040:7c5a:89d6:2e98:9799? ([2602:306:3a25:b040:7c5a:89d6:2e98:9799]) by smtp.googlemail.com with ESMTPSA id a10sm9154057obl.9.2015.08.08.16.27.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Aug 2015 16:27:53 -0700 (PDT) |
| Message-ID | <55C69077.3040703@gmail.com> (permalink) |
| Date | Sat, 08 Aug 2015 16:27:51 -0700 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
| MIME-Version | 1.0 |
| To | Marcos Barbeitos <msbarbeitos@gmail.com>, Kent Fredric <kentfredric@gmail.com> |
| CC | Chris Prather <perigrin@prather.org>, Ben Tilly <btilly@gmail.com>, Moose <moose@perl.org> |
| Subject | Re: 'around' method modifier does not seem to work |
| References | <CANoac9Ukr4rW4f18bfSHFXpBD6EP9krrraSqAvvHBg0hzxx-tg@mail.gmail.com> <1438981770245.5432f7da@Nodemailer> <CAATnKFAv5Gw9sUU3wsDyLSXmphFAEZMF_inKi60yqwhror7jZQ@mail.gmail.com> <CA+gEHsU0j9JkupjdaEjz93byDVGA+9PMNQBEZQrGfhQSmTjrRQ@mail.gmail.com> |
| In-Reply-To | <CA+gEHsU0j9JkupjdaEjz93byDVGA+9PMNQBEZQrGfhQSmTjrRQ@mail.gmail.com> |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Approved | news@nntp.perl.org |
| From | barefootcoder@gmail.com (Buddy Burden) |
Show key headers only | View raw
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 elegant solution, for I must access the
> attribute directly instead of using an accessor.
Well, you have the accessor right there, if you'd like to use it: it's
called `$orig`:
return @_ ? $self->$orig( _get_parsed_sequence(shift) ) : $self->$orig;
> One issue still remains though, if I pass the argument to the constructor:
>
> my $collection = DCSE::Collection->new
> (
> id => 'test'
> , sequence => $sequence
> , helix => $dcse->helix
> );
>
> I believe that 'around' is not called, for I get the unparsed argument
> when I fetch the attribute.
One of the few useful things I learned from C++ that's applicable to
Moose: initialization != assignment. In C++ you'd be stuck with
duplicating some code, but in Moose ...
> I will look into 'writers' and 'readers', maybe they will work better in
> this case?
Look into "triggers." ;->
-- Buddy
Back to perl.moose | Previous | Next — Previous in thread | Next in thread | Find similar
'around' method modifier does not seem to work msbarbeitos@gmail.com (Marcos Barbeitos) - 2015-08-06 20:04 -0300
Re: 'around' method modifier does not seem to work btilly@gmail.com (Ben Tilly) - 2015-08-06 19:02 -0700
Re: 'around' method modifier does not seem to work perigrin@prather.org ("Chris Prather") - 2015-08-07 09:27 -0700
Re: 'around' method modifier does not seem to work btilly@gmail.com (Ben Tilly) - 2015-08-07 11:28 -0700
Re: 'around' method modifier does not seem to work perigrin@prather.org ("Chris Prather") - 2015-08-07 14:09 -0700
Re: 'around' method modifier does not seem to work kentfredric@gmail.com (Kent Fredric) - 2015-08-08 14:31 +1200
Re: 'around' method modifier does not seem to work msbarbeitos@gmail.com (Marcos Barbeitos) - 2015-08-08 17:18 -0300
Re: 'around' method modifier does not seem to work barefootcoder@gmail.com (Buddy Burden) - 2015-08-08 16:27 -0700
Re: 'around' method modifier does not seem to work kentfredric@gmail.com (Kent Fredric) - 2015-08-11 14:15 +1200
csiph-web