class Paperclip::AbstractAdapter

Constants

OS_RESTRICTED_CHARACTERS

Attributes

content_type[R]
length[R]
original_filename[R]
size[R]
tempfile[R]

Public Class Methods

new(target, options = {}) click to toggle source
# File lib/paperclip/io_adapters/abstract_adapter.rb, line 11
def initialize(target, options = {})
  @target = target
  @options = options
end

Public Instance Methods

assignment?() click to toggle source
# File lib/paperclip/io_adapters/abstract_adapter.rb, line 44
def assignment?
  true
end
fingerprint() click to toggle source
# File lib/paperclip/io_adapters/abstract_adapter.rb, line 16
def fingerprint
  @fingerprint ||= begin
    digest = @options.fetch(:hash_digest).new
    File.open(path, "rb") do |f|
      buf = ""
      digest.update(buf) while f.read(16384, buf)
    end
    digest.hexdigest
  end
end
inspect() click to toggle source
# File lib/paperclip/io_adapters/abstract_adapter.rb, line 31
def inspect
  "#{self.class}: #{self.original_filename}"
end
nil?() click to toggle source
# File lib/paperclip/io_adapters/abstract_adapter.rb, line 40
def nil?
  false
end
original_filename=(new_filename) click to toggle source
# File lib/paperclip/io_adapters/abstract_adapter.rb, line 35
def original_filename=(new_filename)
  return unless new_filename
  @original_filename = new_filename.gsub(OS_RESTRICTED_CHARACTERS, "_")
end
read(length = nil, buffer = nil) click to toggle source
# File lib/paperclip/io_adapters/abstract_adapter.rb, line 27
def read(length = nil, buffer = nil)
  @tempfile.read(length, buffer)
end

Private Instance Methods

copy_to_tempfile(src) click to toggle source
# File lib/paperclip/io_adapters/abstract_adapter.rb, line 54
def copy_to_tempfile(src)
  link_or_copy_file(src.path, destination.path)
  destination
end
destination() click to toggle source
# File lib/paperclip/io_adapters/abstract_adapter.rb, line 50
def destination
  @destination ||= TempfileFactory.new.generate(@original_filename.to_s)
end