Class: FileColumn::PermanentUploadedFile

Inherits:
RealUploadedFile show all
Defined in:
lib/file_column.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from BaseUploadedFile

#magick_errors

Instance Method Summary collapse

Methods inherited from RealUploadedFile

#relative_path

Methods inherited from BaseUploadedFile

#absolute_dir, #after_save, #assign, #create_magick_version_if_needed, #has_magick_errors?, #just_uploaded?, #on_save, #options, #relative_dir, #temp_path, #transform_with_magick

Constructor Details

#initialize(*args) ⇒ PermanentUploadedFile

Returns a new instance of PermanentUploadedFile.



361
362
363
364
365
# File 'lib/file_column.rb', line 361

def initialize(*args)
  super *args
  @filename = @instance[@attr]
  @filename = nil if @filename.empty?
end

Instance Method Details

#absolute_path(subdir = nil) ⇒ Object



371
372
373
374
375
376
377
# File 'lib/file_column.rb', line 371

def absolute_path(subdir=nil)
  if subdir
    store.absolute_path(File.join(relative_path_prefix, subdir, @filename))
  else
    store.absolute_path(File.join(relative_path_prefix, @filename))
  end
end

#after_destroyObject



404
405
406
# File 'lib/file_column.rb', line 404

def after_destroy
  delete_files
end

#assign_temp(temp_path) ⇒ Object



397
398
399
400
401
402
# File 'lib/file_column.rb', line 397

def assign_temp(temp_path)
  return nil if temp_path.nil? or temp_path.empty?
  temp = clone_as TempUploadedFile
  temp.parse_temp_path(temp_path)
  temp
end

#deleteObject



390
391
392
393
394
395
# File 'lib/file_column.rb', line 390

def delete
  file = clone_as NoUploadedFile
  @instance[@attr] = ""
  file.on_save { delete_files }
  file
end

#delete_filesObject



408
409
410
# File 'lib/file_column.rb', line 408

def delete_files
  store.delete(relative_path_prefix)
end

#move_from(local_dir, just_uploaded) ⇒ Object



379
380
381
382
# File 'lib/file_column.rb', line 379

def move_from(local_dir, just_uploaded)
  store.upload_dir(relative_path_prefix, local_dir)
  @just_uploaded = just_uploaded
end

#storeObject



367
368
369
# File 'lib/file_column.rb', line 367

def store
  FileColumn.store(store_dir, options)
end

#upload(file) ⇒ Object



384
385
386
387
388
# File 'lib/file_column.rb', line 384

def upload(file)
  temp = clone_as TempUploadedFile
  temp.store_upload(file)
  temp
end