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

Matt S Trout dbix-class at trout.me.uk
Wed Dec 7 02:46:38 CET 2005


On Mon, Dec 05, 2005 at 01:21:00PM -0500, Vsevolod (Simon) Ilyushchenko wrote:
> 
> 
> 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.

But if you were to do

__PACKAGE__->inflate_column('col', { inflate => ..., deflate => ... });

$obj->col would be an accessor to an inflated object. Why not just
inflate/deflate to the DateChecker and EmployeeChecker objects like that?

If this isn't making sense, you could always hop onto IRC again and hassle
me on there :)

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list