Module: Paperclip::InstanceMethods

Defined in:
lib/dm-paperclip.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#attachment_for(name) ⇒ Object



341
342
343
344
# File 'lib/dm-paperclip.rb', line 341

def attachment_for name
  @attachments ||= {}
  @attachments[name] ||= Attachment.new(name, self, self.class.attachment_definitions[name])
end

#destroy_attached_filesObject



359
360
361
362
363
364
365
# File 'lib/dm-paperclip.rb', line 359

def destroy_attached_files
  Paperclip.log("Deleting attachments.")
  each_attachment do |name, attachment|
    attachment.send(:queue_existing_for_delete)
    attachment.send(:flush_deletes)
  end
end

#each_attachmentObject



346
347
348
349
350
# File 'lib/dm-paperclip.rb', line 346

def each_attachment
  self.class.attachment_definitions.each do |name, definition|
    yield(name, attachment_for(name))
  end
end

#save_attached_filesObject



352
353
354
355
356
357
# File 'lib/dm-paperclip.rb', line 352

def save_attached_files
  Paperclip.log("Saving attachments.")
  each_attachment do |name, attachment|
    attachment.send(:save)
  end
end