Class: ActiveStorage::Attached::Changes::CreateMany

Inherits:
Object
  • Object
show all
Defined in:
activestorage/lib/active_storage/attached/changes/create_many.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, record, attachables) ⇒ CreateMany

Returns a new instance of CreateMany.


7
8
9
10
11
# File 'activestorage/lib/active_storage/attached/changes/create_many.rb', line 7

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

Instance Attribute Details

#attachablesObject (readonly)

Returns the value of attribute attachables.


5
6
7
# File 'activestorage/lib/active_storage/attached/changes/create_many.rb', line 5

def attachables
  @attachables
end

#nameObject (readonly)

Returns the value of attribute name.


5
6
7
# File 'activestorage/lib/active_storage/attached/changes/create_many.rb', line 5

def name
  @name
end

#recordObject (readonly)

Returns the value of attribute record.


5
6
7
# File 'activestorage/lib/active_storage/attached/changes/create_many.rb', line 5

def record
  @record
end

Instance Method Details

#attachmentsObject


13
14
15
# File 'activestorage/lib/active_storage/attached/changes/create_many.rb', line 13

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

#blobsObject


17
18
19
# File 'activestorage/lib/active_storage/attached/changes/create_many.rb', line 17

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

#saveObject


25
26
27
28
# File 'activestorage/lib/active_storage/attached/changes/create_many.rb', line 25

def save
  assign_associated_attachments
  reset_associated_blobs
end

#uploadObject


21
22
23
# File 'activestorage/lib/active_storage/attached/changes/create_many.rb', line 21

def upload
  subchanges.each(&:upload)
end