class SimpleFileUploader::BaseUploader
Attributes
mounted_uploaders[R]
column_value[RW]
errors[RW]
model[RW]
mounted_as[RW]
Public Class Methods
find_uploader_by_uuid(uuid)
click to toggle source
# File lib/simple_file_uploader/base_uploader.rb, line 29 def find_uploader_by_uuid(uuid) mounted_uploaders.each do |mounted_uploader| clazz = mounted_uploader[:model_class].constantize found_model = clazz.where(:"#{mounted_uploader[:column]}" => uuid).take return found_model.send(:"#{mounted_uploader[:column]}") if found_model.present? end if mounted_uploaders.present? nil end
new(model, mounted_as)
click to toggle source
# File lib/simple_file_uploader/base_uploader.rb, line 7 def initialize(model, mounted_as) @errors = [] @model, @mounted_as = model, mounted_as @column_value = @model.read_uploader(@mounted_as) end
remember_uploader(model_class, column)
click to toggle source
# File lib/simple_file_uploader/base_uploader.rb, line 24 def remember_uploader(model_class, column) @mounted_uploaders ||= [] @mounted_uploaders << {model_class: model_class.name, column: column} end
Public Instance Methods
plain()
click to toggle source
# File lib/simple_file_uploader/base_uploader.rb, line 17 def plain; column_value; end
validate_callback()
click to toggle source
# File lib/simple_file_uploader/base_uploader.rb, line 19 def validate_callback; end
write_identifier!()
click to toggle source
# File lib/simple_file_uploader/base_uploader.rb, line 13 def write_identifier! @model.write_uploader(@mounted_as, @column_value) end