develooper Front page | perl.moose | Postings from March 2009

Re: triggers and the single meta-attr object

Thread Previous | Thread Next
From:
Stevan Little
Date:
March 29, 2009 18:25
Subject:
Re: triggers and the single meta-attr object
Message ID:
3857CD53-1EF2-4DCD-9575-A55BF7DC12A8@iinteractive.com
On Mar 29, 2009, at 3:59 PM, Hans Dieter Pearcey wrote:
> On Sun, Mar 29, 2009 at 11:40:43AM -0400, Stevan Little wrote:
>> Personally, I don't think we need to pass that meta-attribute, if you
>> really want/need it, then you can do this:
>>
>> trigger => sub {
>>    my $self = shift;
>>    $self->meta->find_attribute_by_name('foo')->...
>>    ...
>> }
>>
>> The only tricky part of the above workaround is that you need to know
>> the name of the attribute in order to get the meta-attribute. But  
>> this
>> shouldn't be too hard to fix/work-around in most cases.
>
> What about passing in the attribute name instead of the meta- 
> attribute?  Then
> there's no trickery necessary at all.  Or a coderef that wraps up  
> getting the
> necessary objects:
>
>  sub { Moose::Util::find_meta($class_name)- 
> >get_attribute($attr_name) }
>
> which requires closing over no objects.


Those all work, but they just make things more confusing I think.

If we want to keep it, lets keep it, but if we don't really have a  
reason, lets just get rid of it.

- Stevan

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