Class: CustomFields::Types::File::FileUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- CustomFields::Types::File::FileUploader
- Defined in:
- lib/custom_fields/types/file.rb
Instance Method Summary collapse
Instance Method Details
#filename ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/custom_fields/types/file.rb', line 85 def filename if original_filename && model.fields[mounted_as.to_s].localized? _original_filename, extension = original_filename.split('.') ["#{_original_filename}_#{::Mongoid::Fields::I18n.locale}", extension].compact.join('.') else original_filename end end |
#present? ⇒ Boolean
81 82 83 |
# File 'lib/custom_fields/types/file.rb', line 81 def present? serializable_hash.present? end |
#set_size_in_model ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/custom_fields/types/file.rb', line 94 def set_size_in_model size_field_name = :"#{mounted_as}_size" return unless model.respond_to?(size_field_name) is_localized = model.fields[mounted_as.to_s].[:localize] key = is_localized ? ::Mongoid::Fields::I18n.locale.to_s : 'default' values = model.send(size_field_name) values[key] = file.size end |