I am writing a plugin that provides drafting for models. A delete action is a draftable action and I do not always want to delete the origin until that deletion is published. So I wrote my own destroy method to help out with this. Everything works exactly as I want things to except, custom callbacks for :before_destroy
and :after_destroy
are no longer being triggered.
Any ideas on how to:
- rebind callbacks to my destroy method
- works some alias_method_chain voodoo
- get a list of model callbacks so I can call them manual
- solve this problem another way
Here is my destroy method:
def destroy
if self.attribute_names.include?('draft') && self.skip_draft == false
if handle_destroy # if true is returned
super # go ahead and destroy as normal
end
else
super
end
end
Update: I just found this: correct way to override activerecordbasedestroy, but that seems like the proposed technique does not accomodate for callbacks either. Is there a way to have my cake and eat it too?