Class: Temper::File
Instance Attribute Summary
Attributes inherited from Base
#content_type, #original_filename
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ File
constructor
A new instance of File.
Methods inherited from Base
#fingerprint, #method_missing, #respond_to?
Constructor Details
#initialize(options = {}) ⇒ File
Returns a new instance of File.
61 62 63 64 65 66 67 68 69 |
# File 'lib/temper.rb', line 61 def initialize( = {}) path = [:content] raise "#{path} file does not exist" if path && !::File.exist?(path) @storage = Tempfile.new("temperfi") @storage.set_encoding(Encoding::BINARY) if @storage.respond_to?(:set_encoding) @storage.binmode unless .key?(:binary) && ![:binary] FileUtils.copy_file(path, @storage.path) if path && !::File.exist?(path) super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Temper::Base