Module: Attached::InstanceMethods
- Defined in:
- lib/attached.rb
Instance Method Summary collapse
-
#attachment_for(name) ⇒ Object
Create or access attachment.
-
#destroy_attached ⇒ Object
Log and destroy all attached (using specified storage).
-
#save_attached ⇒ Object
Log and save all attached (using specified storage).
Instance Method Details
#attachment_for(name) ⇒ Object
Create or access attachment.
Usage:
:avatar
243 244 245 246 |
# File 'lib/attached.rb', line 243 def (name) @_attached_attachments ||= {} @_attached_attachments[name] ||= Attachment.new(name, self, self.class.[name]) end |
#destroy_attached ⇒ Object
Log and destroy all attached (using specified storage).
Usage:
before_save :destroy_attached
270 271 272 273 274 275 276 |
# File 'lib/attached.rb', line 270 def destroy_attached logger.info "[attached] destroy attached" self.class..each do |name, | (name).destroy end end |
#save_attached ⇒ Object
Log and save all attached (using specified storage).
Usage:
before_save :save_attached
255 256 257 258 259 260 261 |
# File 'lib/attached.rb', line 255 def save_attached logger.info "[attached] save attached" self.class..each do |name, | (name).save end end |