Module: Paperclip::InstanceMethods

Defined in:
lib/paperclip.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#attachment_for(name) ⇒ Object



443
444
445
446
# File 'lib/paperclip.rb', line 443

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

#destroy_attached_filesObject



461
462
463
464
465
466
# File 'lib/paperclip.rb', line 461

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

#each_attachmentObject



448
449
450
451
452
# File 'lib/paperclip.rb', line 448

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

#prepare_for_destroyObject



468
469
470
471
472
473
# File 'lib/paperclip.rb', line 468

def prepare_for_destroy
  Paperclip.log("Scheduling attachments for deletion.")
  each_attachment do |name, attachment|
    attachment.send(:queue_existing_for_delete)
  end
end

#save_attached_filesObject



454
455
456
457
458
459
# File 'lib/paperclip.rb', line 454

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