Re: custom accessor_metaclass override of _inline_store (Moose 1 to 2)
[email protected] (Buddy Burden) Wed, 23 Mar 2016 03:46:32 -0700
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
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. -- Buddy [1] https://www.mail-archive.com/[email protected]/msg02318.html [2] https://www.mail-archive.com/[email protected]/msg02341.html