Class: ActiveShrine::Attached::Changes::CreateOne
- Inherits:
-
Object
- Object
- ActiveShrine::Attached::Changes::CreateOne
- Defined in:
- lib/active_shrine/attached/changes/create_one.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attachable ⇒ Object
readonly
Returns the value of attribute attachable.
-
#attachment_class ⇒ Object
readonly
Returns the value of attribute attachment_class.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #attachment ⇒ Object
-
#initialize(name, record, attachment_class, attachable) ⇒ CreateOne
constructor
A new instance of CreateOne.
- #save ⇒ Object
Constructor Details
#initialize(name, record, attachment_class, attachable) ⇒ CreateOne
12 13 14 15 16 17 18 19 |
# File 'lib/active_shrine/attached/changes/create_one.rb', line 12 def initialize(name, record, , attachable) @name = name @record = record = @attachable = attachable attach end |
Instance Attribute Details
#attachable ⇒ Object (readonly)
Returns the value of attribute attachable.
10 11 12 |
# File 'lib/active_shrine/attached/changes/create_one.rb', line 10 def attachable @attachable end |
#attachment_class ⇒ Object (readonly)
Returns the value of attribute attachment_class.
10 11 12 |
# File 'lib/active_shrine/attached/changes/create_one.rb', line 10 def end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/active_shrine/attached/changes/create_one.rb', line 10 def name @name end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
10 11 12 |
# File 'lib/active_shrine/attached/changes/create_one.rb', line 10 def record @record end |
Instance Method Details
#attachment ⇒ Object
21 22 23 |
# File 'lib/active_shrine/attached/changes/create_one.rb', line 21 def ||= end |
#save ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/active_shrine/attached/changes/create_one.rb', line 25 def save unless .valid? .errors.each do |error| record.errors.add(name, error.) end raise ActiveRecord::RecordInvalid.new(record) end record.public_send(:"#{name}_attachment=", ) end |