class Paperclip::UploadedFileAdapter
Attributes
content_type_detector[RW]
Public Class Methods
new(target, options = {})
click to toggle source
Calls superclass method
Paperclip::AbstractAdapter::new
# File lib/paperclip/io_adapters/uploaded_file_adapter.rb, line 9 def initialize(target, options = {}) super cache_current_values @tempfile = if @target.respond_to?(:tempfile) copy_to_tempfile(@target.tempfile) else copy_to_tempfile(@target) end end
register()
click to toggle source
# File lib/paperclip/io_adapters/uploaded_file_adapter.rb, line 3 def self.register Paperclip.io_adapters.register self do |target| target.class.name.include?("UploadedFile") end end
Private Instance Methods
cache_current_values()
click to toggle source
# File lib/paperclip/io_adapters/uploaded_file_adapter.rb, line 26 def cache_current_values self.original_filename = @target.original_filename @content_type = determine_content_type @size = File.size(@target.path) end
content_type_detector()
click to toggle source
# File lib/paperclip/io_adapters/uploaded_file_adapter.rb, line 32 def content_type_detector self.class.content_type_detector || Paperclip::ContentTypeDetector end
determine_content_type()
click to toggle source
# File lib/paperclip/io_adapters/uploaded_file_adapter.rb, line 36 def determine_content_type content_type = @target.content_type.to_s.strip content_type = content_type_detector.new(@target.path).detect if content_type_detector content_type end