+sub save {
+ my ($self, @args) = @_;
+
+ my ($result, $exception);
+ my $worker = sub {
+ $exception = $EVAL_ERROR unless eval {
+ SL::DB::Object::Hooks::run_hooks($self, 'before_save');
+ $result = $self->SUPER::save(@args);
+ SL::DB::Object::Hooks::run_hooks($self, 'after_save', $result);
+ 1;
+ };
+
+ return $result;
+ };
+
+ $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker);
+
+ die $exception if $exception;
+
+ return $result;
+}
+
+sub delete {
+ my ($self, @args) = @_;
+
+ my ($result, $exception);
+ my $worker = sub {
+ $exception = $EVAL_ERROR unless eval {
+ SL::DB::Object::Hooks::run_hooks($self, 'before_delete');
+ $result = $self->SUPER::delete(@args);
+ SL::DB::Object::Hooks::run_hooks($self, 'after_delete', $result);
+ 1;
+ };
+
+ return $result;
+ };
+
+ $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker);
+
+ die $exception if $exception;
+
+ return $result;