123456789_123456789_123456789_123456789_123456789_

Class: ActiveStorage::Attached::Changes::CreateOneOfMany

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, CreateOne
Instance Chain:
self, CreateOne
Inherits: ActiveStorage::Attached::Changes::CreateOne
Defined in: activestorage/lib/active_storage/attached/changes/create_one_of_many.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name, record, attachable, create_many) ⇒ CreateOneOfMany

[ GitHub ]

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

def initialize(name, record, attachable, create_many)
  @create_many = create_many
  super(name, record, attachable)
end

Instance Method Details

#find_attachment (private)

[ GitHub ]

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

def find_attachment
  if blob.persisted?
    @create_many.existing_attachment_for(blob)
  else
    blob.attachments.find { |attachment| attachment.record == record }
  end
end