Yeah, I can see how that'd be useful.
If there was one canonical setter in MOP that was always called, we could
before/after/around it, couldn't we? Is there such a thing?
On Tue, Jul 22, 2008 at 05:52:40PM -0400, Sartak wrote:
> On Tue, Jul 22, 2008 at 10:18 AM, Paul Driver <[EMAIL PROTECTED]> wrote:
> > I think the major benefit of the "around" trigger was being able to filter
> > the value going into the setter. I don't have any use case for 'before'
> > that couldn't be accomplished with older "standard" (after) triggers - so
> > some kind of setter-filter (needs a better name) would probably do just as
> > well. That could be done by a MooseX, potentially.
>
> Anything that depends on the old value would be a use case for
> "before". For example, one of my uses would be:
>
> has type => (
> trigger => {
> before => sub {
> $registry->unregister_tile_by_type($_[0], $_[1]);
> },
> after => sub {
> $registry->register_tile_by_type($_[0], $_[1]);
> },
> },
> );
>
> before is also useful for additional validation. You want to throw the
> exception *before* you set an invalid value.
>
> Shawn