Sha256: 4f7fcbc4fdccd4e8808a2737c4f5fb090ab1b544114de8b43930d8c86e272867
Contents?: true
Size: 926 Bytes
Versions: 1
Compression:
Stored size: 926 Bytes
Contents
# frozen_string_literal: true module Paperclip module PermanentRecords module ActiveRecord extend ActiveSupport::Concern def destroy(force = nil) if paperclip_attachments? && # only when we have paperclip attachments, (!is_permanent? || # if model does not support "safe deletion" ::PermanentRecords.should_force_destroy?(force)) # or if model supports "safe deletion" but it is forced schedule_attachments_for_deletion # => delete the attachments end super(force) end private def paperclip_attachments? self.class.respond_to?(:attachment_definitions) end # (this contains what each of the before_destroy callbacks originally did) def schedule_attachments_for_deletion self.class.attachment_definitions.each_key { |name| send(name).send(:queue_all_for_delete) } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
paperclip-permanent_records-0.7.2 | lib/paperclip/permanent_records/active_record.rb |