Class: Temper::File

Inherits:
Base
  • Object
show all
Defined in:
lib/temper.rb

Instance Attribute Summary

Attributes inherited from Base

#content_type, #original_filename

Instance Method Summary collapse

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(options = {})      
  path = options[: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 options.key?(:binary) && !options[:binary]
  FileUtils.copy_file(path, @storage.path) if path && !::File.exist?(path)            
  super options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Temper::Base