Class: ActiveStorage::Attached::Changes::CreateMany
- Inherits:
-
Object
- Object
- ActiveStorage::Attached::Changes::CreateMany
- Defined in:
- lib/active_storage/attached/changes/create_many.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#attachables ⇒ Object
readonly
Returns the value of attribute attachables.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #attachments ⇒ Object
- #blobs ⇒ Object
-
#initialize(name, record, attachables) ⇒ CreateMany
constructor
A new instance of CreateMany.
- #save ⇒ Object
- #upload ⇒ Object
Constructor Details
#initialize(name, record, attachables) ⇒ CreateMany
Returns a new instance of CreateMany.
7 8 9 10 |
# File '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) end |
Instance Attribute Details
#attachables ⇒ Object (readonly)
Returns the value of attribute attachables.
5 6 7 |
# File 'lib/active_storage/attached/changes/create_many.rb', line 5 def attachables @attachables end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/active_storage/attached/changes/create_many.rb', line 5 def name @name end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
5 6 7 |
# File 'lib/active_storage/attached/changes/create_many.rb', line 5 def record @record end |
Instance Method Details
#attachments ⇒ Object
12 13 14 |
# File 'lib/active_storage/attached/changes/create_many.rb', line 12 def @attachments ||= subchanges.collect(&:attachment) end |
#blobs ⇒ Object
16 17 18 |
# File 'lib/active_storage/attached/changes/create_many.rb', line 16 def blobs @blobs ||= subchanges.collect(&:blob) end |
#save ⇒ Object
24 25 26 27 |
# File 'lib/active_storage/attached/changes/create_many.rb', line 24 def save reset_associated_blobs end |
#upload ⇒ Object
20 21 22 |
# File 'lib/active_storage/attached/changes/create_many.rb', line 20 def upload subchanges.each(&:upload) end |