| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | package DBIx::Class::Journal::EvalWrap; | ||
| 4 | use base qw(DBIx::Class::Journal); | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | |||
| 9 | foreach my $method qw(journal_log_update journal_log_insert journal_log_delete) { | ||
| 10 | local $@; | ||
| 11 | eval "sub $method " . ' { | ||
| 12 | my ( $self, @args ) = @_; | ||
| 13 | local $@; | ||
| 14 | eval { $self->next::method(@args) }; | ||
| 15 | warn $@ if $@; | ||
| 16 | }; 1' || warn $@; | ||
| 17 | } | ||
| 18 | |||
| 19 | __PACKAGE__ | ||
| 20 | |||
| 21 | __END__ | ||
| 22 | |||
| 23 | =pod | ||
| 24 | |||
| 25 | =head1 NAME | ||
| 26 | |||
| 27 | DBIx::Class::Journal::EvalWrap - Wrap all journal ops with an eval { } | ||
| 28 | |||
| 29 | =head1 SYNOPSIS | ||
| 30 | |||
| 31 | __PACKAGE__->journal_component("Journal::EvalWrap"); | ||
| 32 | |||
| 33 | =head1 DESCRIPTION | ||
| 34 | |||
| 35 | This component is a wrapper for the row methods in L<DBIx:Class::Journal> that | ||
| 36 | aides in retrofitting a schema for journaling, by wrapping all the journal CRUD | ||
| 37 | operations with a C<local $@; eval { ... }}. | ||
| 38 | |||
| 39 | This is desirable if you'd rather lose journal data than create runtime errors | ||
| 40 | when retrofitting existing code. | ||
| 41 | |||
| 42 | Use with caution. | ||
| 43 | |||
| 44 | =cut | ||
| 45 | |||
| 46 |