Sha256: b2f1c96df39e28b03eaf442e15487e41f87b8abc67ccc6881936ceceb15f3d17

Contents?: true

Size: 538 Bytes

Versions: 71

Compression:

Stored size: 538 Bytes

Contents

# frozen_string_literal: true

module ActiveStorage
  class Attached::Changes::PurgeOne # :nodoc:
    attr_reader :name, :record, :attachment

    def initialize(name, record, attachment)
      @name, @record, @attachment = name, record, attachment
    end

    def purge
      attachment&.purge
      reset
    end

    def purge_later
      attachment&.purge_later
      reset
    end

    private
      def reset
        record.attachment_changes.delete(name)
        record.public_send("#{name}_attachment=", nil)
      end
  end
end

Version data entries

71 entries across 68 versions & 6 rubygems

Version Path
activestorage-7.0.2.3 lib/active_storage/attached/changes/purge_one.rb
activestorage-7.0.2.2 lib/active_storage/attached/changes/purge_one.rb
activestorage-7.0.2.1 lib/active_storage/attached/changes/purge_one.rb
activestorage-7.0.2 lib/active_storage/attached/changes/purge_one.rb
activestorage-7.0.1 lib/active_storage/attached/changes/purge_one.rb
activestorage-7.0.0 lib/active_storage/attached/changes/purge_one.rb
activestorage-7.0.0.rc3 lib/active_storage/attached/changes/purge_one.rb
activestorage-7.0.0.rc2 lib/active_storage/attached/changes/purge_one.rb
activestorage-7.0.0.rc1 lib/active_storage/attached/changes/purge_one.rb
activestorage-7.0.0.alpha2 lib/active_storage/attached/changes/purge_one.rb
activestorage-7.0.0.alpha1 lib/active_storage/attached/changes/purge_one.rb