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

Alternative to triggers?

Thread Next
Larry Leszczynski
December 2, 2017 02:07
Alternative to triggers?
Message ID:
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". 


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About