module Attach::ModelExtension

Public Class Methods

included(base) click to toggle source
# File lib/attach/model_extension.rb, line 8
def self.included(base)
  base.extend ClassMethods
  base.after_save do
    if @pending_attachment_deletions
      self.attachments.where(:role => @pending_attachment_deletions).destroy_all
    end

    @replaced_attachment&.destroy

    if @pending_attachments
      @pending_attachments.values.each(&:save!)
      @pending_attachments = nil
    end
  end
end