develooper Front page | perl.moose | Postings from December 2017

Re: Alternative to triggers?

Thread Previous | Thread Next
From:
Larry Leszczynski
Date:
December 3, 2017 02:46
Subject:
Re: Alternative to triggers?
Message ID:
1512269155.296202.1192054296.3ABFE069@webmail.messagingengine.com
Thanks for the idea, Jim - I used "after" on the accessors and they do
not get called during the initial object construction.

On Fri, Dec 1, 2017, at 07:23 PM, Jim Bacon wrote:
> Hi, try using an “around” on the accessors. Pretty sure those are not
> used during construction,
> 
> Jim
> 
> > On Dec 1, 2017, at 8:07 PM, Larry Leszczynski <larryl@emailplus.org> wrote:
> > 
> > Hi all -
> > 
> > I have triggers set up on two attributes that check if their values are
> > consistent with each other.  I'm worried that since triggers get called
> > during construction when the values are passed in, it will try to do the
> > check before both of those attributes have been set.  I kinda only want
> > to do the check inside BUILD (at which point I know everything has been
> > set), or later on when one or the other of those attributes changes.
> > 
> > I know how to call my checking code both from inside BUILD and as a
> > trigger, what I don't know is how to make the trigger *not* fire during
> > the initial construction... which makes me wonder whether there is a
> > different/better way to do it without using triggers.
> > 
> > For purposes of discussion assume I have an attribute "color" which can
> > be red/blue/green, and another attribute "size" which can be
> > small/medium/large, and that any combination of color and size is ok
> > except I want to croak if you try to use color "red" with size "small". 
> > 
> > 
> > Thanks!
> > Larry
> 

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