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

Alternative to triggers?

Thread Next
From:
Larry Leszczynski
Date:
December 2, 2017 02:07
Subject:
Alternative to triggers?
Message ID:
1512180421.3561.1191324960.2ABA29F3@webmail.messagingengine.com
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 Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About