Sha256: f56bdf02828db9b17ca7eda0834074ebdce2ad98fd6dc573dc8ae6876822bbe2
Contents?: true
Size: 925 Bytes
Versions: 29
Compression:
Stored size: 925 Bytes
Contents
module Paperclip class AttachmentAdapter < AbstractAdapter def initialize(target) @target, @style = case target when Paperclip::Attachment [target, :original] when Paperclip::Style [target.attachment, target.name] end cache_current_values end private def cache_current_values self.original_filename = @target.original_filename @content_type = @target.content_type @tempfile = copy_to_tempfile(@target) @size = @tempfile.size || @target.size end def copy_to_tempfile(source) if source.staged? FileUtils.cp(source.staged_path(@style), destination.path) else source.copy_to_local_file(@style, destination.path) end destination end end end Paperclip.io_adapters.register Paperclip::AttachmentAdapter do |target| Paperclip::Attachment === target || Paperclip::Style === target end
Version data entries
29 entries across 27 versions & 6 rubygems