[Dbix-class] applying row level methods via Schema::Loader

apv apv at sedition.com
Wed Jul 4 20:24:29 GMT 2007


Terrific. Thanks you guys! I'll probably do the additional base  
class. I had no idea you could autogenerate into modified classes too  
which I'll have to try for another project. Best of both worlds.


–Ashley
-- 


On Jul 4, 2007, at 7:42 AM, Brandon Black wrote:

> On 7/3/07, apv <apv at sedition.com> wrote:
>> I never got around to trying Schema::Loader till now. It's terrific.
>> I swapped out 10 table classes or whatever with one and it works
>> exactly as it should.
>>
>> The thing I want to still be able to do is apply a method to all the
>> table classes, specifically a created field stamp of NOW(). I'm on an
>> older mysql for this project so I can't use triggers. There are dates
>> before the epoch so I'm using DATETIME. This is what I want to do--
>>
>> sub new {
>>      my ( $class, $attrs ) = @_;
>>      $attrs->{created} = \"NOW()" unless $attrs->{created};
>>      $class->next::method($attrs);
>> }
>>
>
> Check the DBIx::Class::Schema::Loader::Base docs, they have info on
> adding additional custom base classes.  If you need to make one-off
> mods to individual files, you can just edit the generated files
> directly, below the md5sum line, and it will be preserved when you
> regenerate the top half again (assuming 0.04001).
>
> -- Brandon
>




More information about the Dbix-class mailing list