From 6876bc0a40cf23520164196e605503a4fb04e7eb Mon Sep 17 00:00:00 2001 From: Ariel Diaz Bermejo Date: Wed, 25 Nov 2015 14:26:57 -0300 Subject: [PATCH] Adding support to 'cancel' restore and real_destroy callbacks if they return false --- lib/paranoia.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/paranoia.rb b/lib/paranoia.rb index 1f3138bc..beaa8082 100644 --- a/lib/paranoia.rb +++ b/lib/paranoia.rb @@ -55,7 +55,7 @@ def restore(id_or_ids, opts = {}) module Callbacks def self.extended(klazz) [:restore, :real_destroy].each do |callback_name| - klazz.define_callbacks callback_name + klazz.define_callbacks callback_name, terminator: ->(_, result) { result == false } klazz.define_singleton_method("before_#{callback_name}") do |*args, &block| set_callback(callback_name, :before, *args, &block)