Module: Paperclip::InstanceMethods

Defined in:
lib/dm-paperclip.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#attachment_for(name) ⇒ Object



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

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

#destroy_attached_filesObject



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

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



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

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

#save_attached_filesObject



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

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