Re: Usage of ref for testing if a passed in reference is a HASH, etc

[prev] [thread] [next] [Date index for 2004/11/17]

From: Tony Bowden
Subject: Re: Usage of ref for testing if a passed in reference is a HASH, etc
Date: 16:48 on 17 Nov 2004
On Wed, Nov 17, 2004 at 10:43:51AM -0500, Michael Henson wrote:
> I was referring to just testing to ensure it is the correct data type.
> Right now ->create work likes this:
> return $class->_croak("create needs a hashref") unless ref $_[0] eq 'HASH';
> Which is all well and good, but it doesn't allow you to do things like
> this:
> my $foo = bless( { name => 'Testing', prop1 => 2 },
> 'SomeClassOrAnother' );
> my $obj = OurClassDBIPkg->create( $foo );

I see that as a feature, not as a bug.

I'm certainly open to persuasion, but if you're really going to be
passing objects to create, I think you want a before_create() trigger to
tidy that up for you.

Tony

Re: Usage of ref for testing if a passed in reference is a HASH, etc
Tony Bowden 16:48 on 17 Nov 2004

Generated at 17:31 on 15 Feb 2005 by mariachi v0.52