Class: FileColumn::PermanentUploadedFile
Overview
Instance Method Summary
collapse
#relative_path
#absolute_dir, #after_save, #assign, #just_uploaded?, #on_save, #options, #relative_dir, #temp_path
Constructor Details
Returns a new instance of PermanentUploadedFile.
360
361
362
363
364
|
# File 'lib/file_column.rb', line 360
def initialize(*args)
super *args
@filename = @instance[@attr]
@filename = nil if @filename.empty?
end
|
Instance Method Details
#absolute_path(subdir = nil) ⇒ Object
370
371
372
373
374
375
376
|
# File 'lib/file_column.rb', line 370
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_destroy ⇒ Object
403
404
405
|
# File 'lib/file_column.rb', line 403
def after_destroy
delete_files
end
|
#assign_temp(temp_path) ⇒ Object
396
397
398
399
400
401
|
# File 'lib/file_column.rb', line 396
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
389
390
391
392
393
394
|
# File 'lib/file_column.rb', line 389
def delete
file = clone_as NoUploadedFile
@instance[@attr] = ""
file.on_save { delete_files }
file
end
|
#delete_files ⇒ Object
407
408
409
|
# File 'lib/file_column.rb', line 407
def delete_files
store.delete(relative_path_prefix)
end
|
#move_from(local_dir, just_uploaded) ⇒ Object
378
379
380
381
|
# File 'lib/file_column.rb', line 378
def move_from(local_dir, just_uploaded)
store.upload_dir(relative_path_prefix, local_dir)
@just_uploaded = just_uploaded
end
|
#store ⇒ Object
366
367
368
|
# File 'lib/file_column.rb', line 366
def store
FileColumn.store(store_dir, options)
end
|
#upload(file) ⇒ Object
383
384
385
386
387
|
# File 'lib/file_column.rb', line 383
def upload(file)
temp = clone_as TempUploadedFile
temp.store_upload(file)
temp
end
|