Re: xor attributes

2009-11-26 Thread Evan Carroll
On Thu, Nov 26, 2009 at 10:46 AM, Ovid publiustemp-catal...@yahoo.com wrote: I have two attributes, 'xml' and 'xml_file' for an object.  One or the other must be supplied, but not both. Must I validated this in BUILD or is there another way of doing this? Well, I would use a trigger and

Re: xor attributes

2009-11-26 Thread Stevan Little
Nope, BUILD is where you want to do this. Would make a nice MooseX:: though :) - Stevan On Nov 26, 2009, at 11:46 AM, Ovid wrote: I have two attributes, 'xml' and 'xml_file' for an object. One or the other must be supplied, but not both. Must I validated this in BUILD or is there another

Re: xor attributes

2009-11-26 Thread Dan Horne
Yes - I often need user, pass and dsn strings for a DBI connection or a DBI::db object. What would be the best pattern to deal with such cases if one were to generalise it? On 27/11/2009, at 06:05 AM, Stevan Little wrote: Nope, BUILD is where you want to do this. Would make a nice MooseX::

Re: xor attributes

2009-11-26 Thread Jeffrey Ray
Dan Horne wrote: Yes - I often need user, pass and dsn strings for a DBI connection or a DBI::db object. What would be the best pattern to deal with such cases if one were to generalise it? I often take care of this using type coercion: package Object; use Moose; use

Re: xor attributes

2009-11-26 Thread Darren Duncan
Dan Horne wrote: Yes - I often need user, pass and dsn strings for a DBI connection or a DBI::db object. What would be the best pattern to deal with such cases if one were to generalise it? If you want to generalize the connection info for a database, the best way to do it is just use a

Re: xor attributes

2009-11-26 Thread Stevan Little
Jeffrey++ Ah yes, I always forget about the coercion too. I do this sometimes as well, the only issue being that you sometimes want to still have access to the original information, etc. Which in some cases you can just do via delegation on the constructed object. - Stevan On Nov 26,