attachinary icon indicating copy to clipboard operation
attachinary copied to clipboard

Callbacks?

Open npearson72 opened this issue 10 years ago • 1 comments

I need to hook into the destroy method. Any ideas?

npearson72 avatar Mar 06 '15 00:03 npearson72

Hi @npearson72,

You can use alias_method (or alias_method_chain if you are using Rails) to achieve this. For (a partial) example:

module Attachinary
  module FileMixin
    def destroy_hook
      # your code here
      destroy_file_orig
    end
    alias_method :destroy_file_orig, :destroy_file
    alias_method :destroy_file, :destroy_hook
  end
end

tocker avatar May 11 '15 14:05 tocker