[Dbix-class] Overriding Standard Methods

michael reddick michael.reddick at gmail.com
Wed Dec 3 15:54:10 GMT 2008


On Wed, Dec 3, 2008 at 9:19 AM, Dave Cross <dave at dave.org.uk> wrote:

>
> I think I'm missing something obvious here. Feel free to point out my
> stupidity.
>
> I have a set of DBIC classes that have been generated by Schema::Loader.
> I want to overload the "delete" method so that instead of actually
> deleting the row the deleted flag gets set to true[1].
>
> I can add a method to the class like this:
>
> sub rm {
>  my $self =3D shift;
>
>  $self->deleted(1);
>  $self->update;
> }
>
> and call "rm" instead of "delete". Then everything works. But I don't
> want to call the method "rm", I want to call it "delete". If I call it
> delete, then my method doesn't get called. It goes into
> DBIx::Class::Relationship::CascadeActions::delete and that passes
> control to DBIx::Class::Row::delete - completely missing my method.
>
> What am I missing?
>
> Cheers,
>
> Dave...
>
> [1] Yes, this should be a trigger. But triggers are banned from this
> database.
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>


Looks like you need a override delete in a component

http://search.cpan.org/~ash/DBIx-Class-0.08010/lib/DBIx/Class/Manual/Compon=
ent.pod
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20081203/f16=
24be3/attachment.htm


More information about the DBIx-Class mailing list