123456789_123456789_123456789_123456789_123456789_

Class: ActiveStorage::Attached::Changes::DetachMany

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

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name, record, attachments) ⇒ DetachMany

[ GitHub ]

  
# File 'activestorage/lib/active_storage/attached/changes/detach_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/detach_many.rb', line 5

attr_reader :name, :record, :attachments

#name (readonly)

[ GitHub ]

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

attr_reader :name, :record, :attachments

#record (readonly)

[ GitHub ]

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

attr_reader :name, :record, :attachments

Instance Method Details

#detach

[ GitHub ]

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

def detach
  if attachments.any?
    attachments.delete_all if attachments.respond_to?(:delete_all)
    record.attachment_changes.delete(name)
  end
end