Last active
August 29, 2015 14:01
-
-
Save D1plo1d/ec857c759cb2b1828bd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HardDestroyCallbacks | |
extend ActiveSupport::Concern | |
included do | |
define_callbacks :hard_destroy | |
around_destroy :run_hard_destroy_callbacks | |
def run_hard_destroy_callbacks | |
return yield unless deleted_at.present? | |
run_callbacks :hard_destroy do | |
yield | |
end | |
end | |
end | |
module ClassMethods | |
def before_hard_destroy(&block) | |
set_callback :hard_destroy, :before, &block | |
end | |
def after_hard_destroy(&block) | |
set_callback :hard_destroy, :after, &block | |
end | |
def around_hard_destroy(&block) | |
set_callback :hard_destroy, :around, &block | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment