Class: Paperclip::AbstractAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/paperclip/io_adapters/abstract_adapter.rb

Constant Summary collapse

OS_RESTRICTED_CHARACTERS =
%r{[/:]}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, options = {}) ⇒ AbstractAdapter

Returns a new instance of AbstractAdapter.



13
14
15
16
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 13

def initialize(target, options = {})
  @target = target
  @options = options
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



9
10
11
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 9

def content_type
  @content_type
end

#original_filenameObject

Returns the value of attribute original_filename.



9
10
11
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 9

def original_filename
  @original_filename
end

#sizeObject (readonly) Also known as: length

Returns the value of attribute size.



9
10
11
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 9

def size
  @size
end

#tempfileObject (readonly)

Returns the value of attribute tempfile.



9
10
11
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 9

def tempfile
  @tempfile
end

Instance Method Details

#assignment?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 47

def assignment?
  true
end

#fingerprintObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 18

def fingerprint
  @fingerprint ||= begin
    digest = @options.fetch(:hash_digest).new
    File.open(path, "rb") do |f|
      buf = String.new
      digest.update(buf) while f.read(16384, buf)
    end
    digest.hexdigest
  end
end

#inspectObject



33
34
35
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 33

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

#nil?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 43

def nil?
  false
end

#read(length = nil, buffer = nil) ⇒ Object



29
30
31
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 29

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