[Dbix-class] new() and initialize()

Vsevolod (Simon) Ilyushchenko simonf at cshl.edu
Mon Dec 5 19:21:00 CET 2005



Matt S Trout wrote on 12/02/2005 09:49 PM:
> On Wed, Nov 30, 2005 at 07:28:12PM -0500, Vsevolod (Simon) Ilyushchenko wrote:
> 
>>Hi,
>>
>>I've upgraded to 0.04, but the problem with new() and initialize() that 
>>I had persists. I though that by putting my model superclass in the 
>>begininng of ISA, I'd be able to override new() to perform 
>>class-specific initialization.
>>
>>However, when relationships are followed, new instances are blessed in 
>>DBIx::Class::Row::_row_to_object - new() is never called! I can probably 
>>override this method, but that would we *wrong*. What else can I do?
> 
> 
> I've probably asked this before, but what are you trying to achieve here?
> 
> Can't any non-persistent information be lazily generated at run-time? If
> not, why isn't it persisted already?
> 
> (_row_to_object should soon morph into a public inflation interface as I
> refactor, but for the moment it's probably not a good target).

I'm storing DateChecker and EmployeeChecker objects as model's instance 
variables. The right way to do this is probably to use "inflate" for the 
respective columns, but for now I'm concentrating on rewriting existing 
applications with minimal other changes, and they use Date/EmployeeCheckers.

Simon

-- 

Simon (Vsevolod ILyushchenko)   simonf at cshl.edu
				http://www.simonf.com

"Think like a man of action, act like a man of thought."

		         Henri Bergson



More information about the Dbix-class mailing list