Hi everyone,

I needed to run a method after every save (I add stuff to a log table  
and want the code to automatically update an RRD table too).

After unsuccessfully fiddling with column level triggers for a bit, I  
realized I could just override save:

sub save {
     my $self = shift;
     my $rv = $self->SUPER::save(@_);
     $self->update_rrd;
     $rv;
}

For another class I'd like to just do the extra work before and after  
the initial object creation and I noticed that save() seems to call  
insert() or update() as appropriate. So yay - that was easy too:

sub insert {
     my $self = shift;

     $self->join_zone('.');

     $self->SUPER::insert(@_);

     my $start_score = -5;
     my $ls = $self->add_log_scores({ step => 1, score =>  
$start_score, offset => 0 });
     $self->score_raw($start_score);
     $self->save(cascade => 1);
     $self->update_graphs;
}


  - ask

-- 
http://develooper.com/ - http://askask.com/



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to