Sha256: b7e52909828e3b0f941a508004dca309bf015743c2a6c1f1a98320bf5f4b8410

Contents?: true

Size: 919 Bytes

Versions: 7

Compression:

Stored size: 919 Bytes

Contents

module Paperclip
  module InstanceMethods #:nodoc:
    def attachment_for name
      @_paperclip_attachments ||= {}
      @_paperclip_attachments[name] ||= Attachment.new(name, self, attachment_definitions[name])
    end

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

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
paperclip-3.4.2 lib/paperclip/instance_methods.rb
paperclip-3.4.1 lib/paperclip/instance_methods.rb
paperclip-3.4.0 lib/paperclip/instance_methods.rb
paperclip-3.3.1 lib/paperclip/instance_methods.rb
paperclip-3.2.1 lib/paperclip/instance_methods.rb
paperclip-3.3.0 lib/paperclip/instance_methods.rb
paperclip-3.2.0 lib/paperclip/instance_methods.rb