Class: FileColumn::PermanentUploadedFile
Overview
Instance Attribute Summary
#magick_errors
Instance Method Summary
collapse
#absolute_path, #relative_path
#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
Returns a new instance of PermanentUploadedFile.
347
348
349
350
351
352
353
|
# File 'lib/file_column.rb', line 347
def initialize(*args)
super *args
@dir = File.join(store_dir, relative_path_prefix)
@filename = @instance[@attr]
@filename = nil if @filename.empty?
FileUtils.mkpath(File.dirname(@dir)) unless File.exists?(File.dirname(@dir))
end
|
Instance Method Details
#after_destroy ⇒ Object
388
389
390
|
# File 'lib/file_column.rb', line 388
def after_destroy
delete_files
end
|
#assign_temp(temp_path) ⇒ Object
380
381
382
383
384
385
386
|
# File 'lib/file_column.rb', line 380
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
|
#delete ⇒ Object
373
374
375
376
377
378
|
# File 'lib/file_column.rb', line 373
def delete
file = clone_as NoUploadedFile
@instance[@attr] = ""
file.on_save { delete_files }
file
end
|
#delete_files ⇒ Object
392
393
394
|
# File 'lib/file_column.rb', line 392
def delete_files
FileUtils.rm_rf @dir
end
|
#move_from(local_dir, just_uploaded) ⇒ Object
355
356
357
358
359
360
361
362
363
364
365
|
# File 'lib/file_column.rb', line 355
def move_from(local_dir, just_uploaded)
FileUtils.rm_rf @dir
FileUtils.mv local_dir, @dir
@just_uploaded = just_uploaded
end
|
#upload(file) ⇒ Object
367
368
369
370
371
|
# File 'lib/file_column.rb', line 367
def upload(file)
temp = clone_as TempUploadedFile
temp.store_upload(file)
temp
end
|