Module: Ksk::Asset

Extended by:
ActiveSupport::Concern
Defined in:
lib/actives/asset.rb

Instance Method Summary collapse

Instance Method Details

#allow_only_imagesObject



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

Returns:

  • (Boolean)


40
41
42
# File 'lib/actives/asset.rb', line 40

def has_preview?
  preview && preview.assets.any?
end

#is_image?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/actives/asset.rb', line 36

def is_image?
  IMGTYPE.include?(file.content_type)
end

#preview_fileObject



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_positionObject



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_sObject



50
51
52
# File 'lib/actives/asset.rb', line 50

def to_bhf_s
  "ID: #{id} - Name: #{file_file_name}"
end