Class: ActiveStorage::Attached::Changes::CreateOne
- Defined in:
- activestorage/lib/active_storage/attached/changes/create_one.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attachable ⇒ Object
readonly
Returns the value of attribute attachable.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #analyze ⇒ Object
- #attachment ⇒ Object
- #blob ⇒ Object
-
#initialize(name, record, attachable) ⇒ CreateOne
constructor
A new instance of CreateOne.
- #save ⇒ Object
- #upload ⇒ Object
Constructor Details
#initialize(name, record, attachable) ⇒ CreateOne
Returns a new instance of CreateOne.
10 11 12 13 |
# File 'activestorage/lib/active_storage/attached/changes/create_one.rb', line 10 def initialize(name, record, attachable) @name, @record, @attachable = name, record, attachable blob.identify_without_saving end |
Instance Attribute Details
#attachable ⇒ Object (readonly)
Returns the value of attribute attachable.
8 9 10 |
# File 'activestorage/lib/active_storage/attached/changes/create_one.rb', line 8 def attachable @attachable end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'activestorage/lib/active_storage/attached/changes/create_one.rb', line 8 def name @name end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
8 9 10 |
# File 'activestorage/lib/active_storage/attached/changes/create_one.rb', line 8 def record @record end |
Instance Method Details
#analyze ⇒ Object
15 16 17 |
# File 'activestorage/lib/active_storage/attached/changes/create_one.rb', line 15 def analyze with_local_io { blob.analyze_without_saving unless blob.analyzed? } if analyze_immediately? end |
#attachment ⇒ Object
19 20 21 |
# File 'activestorage/lib/active_storage/attached/changes/create_one.rb', line 19 def @attachment ||= end |
#blob ⇒ Object
23 24 25 |
# File 'activestorage/lib/active_storage/attached/changes/create_one.rb', line 23 def blob @blob ||= find_or_build_blob end |
#save ⇒ Object
33 34 35 36 |
# File 'activestorage/lib/active_storage/attached/changes/create_one.rb', line 33 def save record.public_send("#{name}_attachment=", ) record.public_send("#{name}_blob=", blob) end |
#upload ⇒ Object
27 28 29 30 31 |
# File 'activestorage/lib/active_storage/attached/changes/create_one.rb', line 27 def upload if io = open_attachable_io .uploaded(io: io) end end |