Class: Paperclip::AbstractAdapter
- Inherits:
-
Object
- Object
- Paperclip::AbstractAdapter
- Defined in:
- lib/paperclip/io_adapters/abstract_adapter.rb
Direct Known Subclasses
AttachmentAdapter, EmptyStringAdapter, FileAdapter, IdentityAdapter, NilAdapter, StringioAdapter, UploadedFileAdapter, UriAdapter
Constant Summary collapse
- OS_RESTRICTED_CHARACTERS =
%r{[/:]}.freeze
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#original_filename ⇒ Object
Returns the value of attribute original_filename.
-
#size ⇒ Object
(also: #length)
readonly
Returns the value of attribute size.
-
#tempfile ⇒ Object
readonly
Returns the value of attribute tempfile.
Instance Method Summary collapse
- #assignment? ⇒ Boolean
- #fingerprint ⇒ Object
-
#initialize(target, options = {}) ⇒ AbstractAdapter
constructor
A new instance of AbstractAdapter.
- #inspect ⇒ Object
- #nil? ⇒ Boolean
- #read(length = nil, buffer = nil) ⇒ Object
Constructor Details
#initialize(target, options = {}) ⇒ AbstractAdapter
Returns a new instance of AbstractAdapter.
11 12 13 14 |
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 11 def initialize(target, = {}) @target = target @options = end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
7 8 9 |
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 7 def content_type @content_type end |
#original_filename ⇒ Object
Returns the value of attribute original_filename.
7 8 9 |
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 7 def original_filename @original_filename end |
#size ⇒ Object (readonly) Also known as: length
Returns the value of attribute size.
7 8 9 |
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 7 def size @size end |
#tempfile ⇒ Object (readonly)
Returns the value of attribute tempfile.
7 8 9 |
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 7 def tempfile @tempfile end |
Instance Method Details
#assignment? ⇒ Boolean
45 46 47 |
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 45 def assignment? true end |
#fingerprint ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# 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 ⇒ Object
31 32 33 |
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 31 def inspect "#{self.class}: #{original_filename}" end |
#nil? ⇒ Boolean
41 42 43 |
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 41 def nil? false end |
#read(length = nil, buffer = nil) ⇒ Object
27 28 29 |
# File 'lib/paperclip/io_adapters/abstract_adapter.rb', line 27 def read(length = nil, buffer = nil) @tempfile.read(length, buffer) end |