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/moose@perl.org/msg02318.html
[2] https://www.mail-archive.com/moose@perl.org/msg02341.html

Reply via email to