Module: Ksk::Asset
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/actives/asset.rb
Instance Method Summary collapse
- #allow_only_images ⇒ Object
- #has_preview? ⇒ Boolean
- #is_image? ⇒ Boolean
- #preview_file ⇒ Object
- #set_last_position ⇒ Object
- #to_bhf_s ⇒ Object
Instance Method Details
#allow_only_images ⇒ Object
30 31 32 33 34 |
# File 'lib/actives/asset.rb', line 30 def allow_only_images if !(file.content_type =~ %r{^(image|(x-)?application)/(x-png|pjpeg|jpeg|jpg|png|gif)$}) return false end end |
#has_preview? ⇒ Boolean
40 41 42 |
# File 'lib/actives/asset.rb', line 40 def has_preview? preview && preview.assets.any? end |
#is_image? ⇒ Boolean
36 37 38 |
# File 'lib/actives/asset.rb', line 36 def is_image? IMGTYPE.include?(file.content_type) end |
#preview_file ⇒ Object
44 45 46 47 48 |
# File 'lib/actives/asset.rb', line 44 def preview_file if has_preview? preview.assets.first.file end end |
#set_last_position ⇒ Object
54 55 56 |
# File 'lib/actives/asset.rb', line 54 def set_last_position self.position = self.class.where(fileable_id: self.fileable_id).count+1 end |
#to_bhf_s ⇒ Object
50 51 52 |
# File 'lib/actives/asset.rb', line 50 def to_bhf_s "ID: #{id} - Name: #{file_file_name}" end |