Module: Paperclip::InstanceMethods

Defined in:
lib/paperclip/instance_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#attachment_for(name) ⇒ Object



3
4
5
6
# File 'lib/paperclip/instance_methods.rb', line 3

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

#destroy_attached_filesObject



21
22
23
24
25
26
# File 'lib/paperclip/instance_methods.rb', line 21

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

#each_attachmentObject



8
9
10
11
12
# File 'lib/paperclip/instance_methods.rb', line 8

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

#prepare_for_destroyObject



28
29
30
31
32
33
# File 'lib/paperclip/instance_methods.rb', line 28

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

#save_attached_filesObject



14
15
16
17
18
19
# File 'lib/paperclip/instance_methods.rb', line 14

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