class ActiveStorage::Attached::Changes::CreateMany

:nodoc:

def assign_associated_attachments

def assign_associated_attachments
  record.public_send("#{name}_attachments=", persisted_or_new_attachments)
end

def attachments

def attachments
  @attachments ||= subchanges.collect(&:attachment)
end

def blobs

def blobs
  @blobs ||= subchanges.collect(&:blob)
end

def build_subchange_from(attachable)

def build_subchange_from(attachable)
  ActiveStorage::Attached::Changes::CreateOneOfMany.new(name, record, attachable)
end

def initialize(name, record, attachables)

def initialize(name, record, attachables)
  @name, @record, @attachables = name, record, Array(attachables)
  blobs.each(&:identify_without_saving)
  attachments
end

def persisted_or_new_attachments

def persisted_or_new_attachments
  attachments.select { |attachment| attachment.persisted? || attachment.new_record? }
end

def reset_associated_blobs

def reset_associated_blobs
  record.public_send("#{name}_blobs").reset
end

def save

def save
  assign_associated_attachments
  reset_associated_blobs
end

def subchanges

def subchanges
  @subchanges ||= attachables.collect { |attachable| build_subchange_from(attachable) }
end

def upload

def upload
  subchanges.each(&:upload)
end