123456789_123456789_123456789_123456789_123456789_

Class: ActiveStorage::Attached::Changes::PurgeMany

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

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name, record, attachments) ⇒ PurgeMany

[ GitHub ]

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

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

Instance Attribute Details

#attachments (readonly)

[ GitHub ]

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

attr_reader :name, :record, :attachments

#name (readonly)

[ GitHub ]

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

attr_reader :name, :record, :attachments

#record (readonly)

[ GitHub ]

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

attr_reader :name, :record, :attachments

Instance Method Details

#purge

[ GitHub ]

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

def purge
  attachments.each(&:purge)
  reset
end

#purge_later

[ GitHub ]

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

def purge_later
  attachments.each(&:purge_later)
  reset
end

#reset (private)

[ GitHub ]

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

def reset
  record.attachment_changes.delete(name)
  record.public_send("#{name}_attachments").reset
end