Sha256: 1c6354aa0ec0020e000af9272120ca84ed3d9823e8e3a4672affa74995d4b301

Contents?: true

Size: 700 Bytes

Versions: 4

Compression:

Stored size: 700 Bytes

Contents

require 'active_support/core_ext/module/delegation'

module Paperclip
  class AbstractAdapter
    attr_reader :content_type, :original_filename, :size
    delegate :close, :closed?, :eof?, :path, :rewind, :unlink, :to => :@tempfile

    def fingerprint
      @fingerprint ||= Digest::MD5.file(path).to_s
    end

    def read(length = nil, buffer = nil)
      @tempfile.read(length, buffer)
    end

    def inspect
      "#{self.class}: #{self.original_filename}"
    end

    private

    def destination
      @destination ||= TempfileFactory.new.generate(original_filename)
    end

    def copy_to_tempfile(src)
      FileUtils.cp(src.path, destination.path)
      destination
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paperclip-3.2.1 lib/paperclip/io_adapters/abstract_adapter.rb
paperclip-3.3.0 lib/paperclip/io_adapters/abstract_adapter.rb
paperclip-3.2.0 lib/paperclip/io_adapters/abstract_adapter.rb
paperclip-3.1.4 lib/paperclip/io_adapters/abstract_adapter.rb