Module: Locomotive::CarrierWave::Uploader::Asset
- Extended by:
- ActiveSupport::Concern
- Included in:
- Locomotive::ContentAssetUploader, ThemeAssetUploader
- Defined in:
- lib/locomotive/carrierwave/asset.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #image?(file) ⇒ Boolean
- #set_content_type_of_model(*args) ⇒ Object
- #set_size(*args) ⇒ Object
- #set_width_and_height ⇒ Object
Instance Method Details
#image?(file) ⇒ Boolean
65 66 67 |
# File 'lib/locomotive/carrierwave/asset.rb', line 65 def image?(file) model.image? end |
#set_content_type_of_model(*args) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/locomotive/carrierwave/asset.rb', line 34 def set_content_type_of_model(*args) value = :other content_type = file.content_type if content_type.blank? || content_type == 'application/octet-stream' content_type = File.mime_type?(original_filename) end self.class.content_types.each_pair do |type, rules| rules.each do |rule| case rule when String then value = type if content_type == rule when Regexp then value = type if (content_type =~ rule) == 0 end end end model.content_type = value end |
#set_size(*args) ⇒ Object
54 55 56 |
# File 'lib/locomotive/carrierwave/asset.rb', line 54 def set_size(*args) model.size = file.size end |