def initialize(obj, meta={})
if obj.is_a? TempObject
@data = obj.get_data
@tempfile = obj.get_tempfile
@pathname = obj.get_pathname
elsif obj.is_a? String
@data = obj
elsif obj.is_a? Tempfile
@tempfile = obj
elsif obj.is_a? File
@pathname = Pathname.new(obj.path)
elsif obj.is_a? Pathname
@pathname = obj
elsif obj.respond_to?(:tempfile)
@tempfile = obj.tempfile
elsif obj.respond_to?(:path)
@pathname = Pathname.new(obj.path)
else
raise ArgumentError, "#{self.class.name} must be initialized with a String, a Pathname, a File, a Tempfile, another TempObject, something that responds to .tempfile, or something that responds to .path"
end
@tempfile.close if @tempfile
@original_filename = if obj.respond_to?(:original_filename)
obj.original_filename
elsif @pathname
@pathname.basename.to_s
end
@meta = meta
@meta[:name] ||= @original_filename if @original_filename
end