[Dbix-class] on_field_change DBIC hooks
melo at simplicidade.org
Sun Jul 29 22:56:37 GMT 2007
On Jul 29, 2007, at 2:08 PM, Matt S Trout wrote:
> On Sun, Jul 29, 2007 at 09:36:09AM +0100, Pedro Melo wrote:
>> I implementing a "on_field_change" hook. External classes can hook
>> the DBIC model to observe (usually) status changes and start some
>> business logic processes. The reason I choose this approach is that
>> it creates a loosely coupled system, where I can add other components
>> later without going back and modifying old code.
> Hook how?
> On a class base, a schema object base, a resultsource base, a
> base, a per-object base?
Class base for now. It solves my problem. but I don't mind to code it
differently if somebody needs the others.
Personally I only need class hooks.
>> From my first look through the code, I think the set_column() is the
>> proper place to do this. But we could set_column() and then not
> Or store_column if you only want -actual- sets rather than "maybe a
> (the value equality and dirty_columns logic is in set_)
Missed store_column, I'll take a look.
>> So update() and look at the dirty columns is probably safer.
>> If I want to trigger on insert also, I also have to watch for
>> Another option is to create an InflateColumn::Trigger and use that,
>> but it might not be what people expect.
> No. You might like to have a look at the implementation of
> and consider doing something similar for Class::Observer rather than
> Class::Trigger though.
Thanks for the pointers. I knew about Class::Observable already, I've
used it in the past.
XMPP ID: melo at simplicidade.org
More information about the Dbix-class