123456789_123456789_123456789_123456789_123456789_

Class: ActiveStorage::Attached::Changes::PurgeOne

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: activestorage/lib/active_storage/attached/changes/purge_one.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name, record, attachment) ⇒ PurgeOne

[ GitHub ]

  
# File 'activestorage/lib/active_storage/attached/changes/purge_one.rb', line 7

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

Instance Attribute Details

#attachment (readonly)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/attached/changes/purge_one.rb', line 5

attr_reader :name, :record, :attachment

#name (readonly)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/attached/changes/purge_one.rb', line 5

attr_reader :name, :record, :attachment

#record (readonly)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/attached/changes/purge_one.rb', line 5

attr_reader :name, :record, :attachment

Instance Method Details

#purge

[ GitHub ]

  
# File 'activestorage/lib/active_storage/attached/changes/purge_one.rb', line 11

def purge
  attachment&.purge
  reset
end

#purge_later

[ GitHub ]

  
# File 'activestorage/lib/active_storage/attached/changes/purge_one.rb', line 16

def purge_later
  attachment&.purge_later
  reset
end

#reset (private)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/attached/changes/purge_one.rb', line 22

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