Class: TomifyUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- TomifyUploader
- Includes:
- CarrierWave::MiniMagick
- Defined in:
- app/uploaders/tomify_uploader.rb
Instance Method Summary collapse
Instance Method Details
#filename ⇒ Object
8 9 10 |
# File 'app/uploaders/tomify_uploader.rb', line 8 def filename "#{secure_token}.#{file.extension}" if original_filename.present? end |
#image?(new_file) ⇒ Boolean
17 18 19 |
# File 'app/uploaders/tomify_uploader.rb', line 17 def image?(new_file) new_file.content_type.downcase.include? "image" rescue false end |
#secure_token ⇒ Object
12 13 14 15 |
# File 'app/uploaders/tomify_uploader.rb', line 12 def secure_token var = :"@#{mounted_as}_secure_token" model.instance_variable_get(var) || model.instance_variable_set(var, SecureRandom.uuid) end |
#store_dir ⇒ Object
4 5 6 |
# File 'app/uploaders/tomify_uploader.rb', line 4 def store_dir self.class.name.downcase.chomp("uploader").chomp("image") end |