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

Re: custom accessor_metaclass override of _inline_store (Moose 1 to2)

Thread Previous | Thread Next
From:
Toby Blake
Date:
March 23, 2016 11:26
Subject:
Re: custom accessor_metaclass override of _inline_store (Moose 1 to2)
Message ID:
6F094863-E1C0-43B0-B711-5D05121A7DBB@inf.ed.ac.uk
> On 23 Mar 2016, at 10:46, Buddy Burden <barefootcoder@gmail.com> wrote:
> 
> Toby,
> 
>> All these attributes to which I want to apply this trigger share the same
>> trait, so there's a logical association between the two.  Is there a way I
>> can utilise this, so I don't have to define 'trigger => ....' for every
>> attribute which uses this trait, i.e.  have a trigger built into an
>> attribute trait, if that makes sense?
> 
> Well, I once put together an attribute trait that creates default subs (the discussion of which took place on this very list[1]), so I don't see any reason you couldn't do the same with triggers.  Of course, then the trick is, is adding a trait to every attribute any better than adding a trigger to every attribute?  Perhaps you could get around that by doing something to the metaclass, or perhaps your attributes _already_ all have a trait that you can piggyback on (I wasn't quite clear on that part).
> 
> Anyway, I hope that discussion has something useful in it, particularly what I ended up with for my final solution.[2]  I've used that pattern a few times over the past few years.

Thanks Buddy, I'll take a look a proper read-through of the thread and see
what I can do.  It certainly sounds useful.

As to your question, yes the attributes in question already consume the
trait(s) I want to expand.

Cheers
Toby


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


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