Class: Ckeditor::Asset

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
AssetSearch, Orm::ActiveRecord::AssetBase, Elasticsearch::Model, Elasticsearch::Model::Callbacks
Defined in:
app/models/ckeditor/asset.rb

Direct Known Subclasses

AttachmentFile, Picture

Constant Summary collapse

SIZE_RANGE =
{
  '< 25 KB' => 0..25,
  '25 KB to 100 KB' => 25..100,
  '100 KB to 500 KB' => 100..500,
  '500 KB to 1 MB' => 500..1000,
  '> 1 MB' => 1000..999999
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.policy_classObject



45
46
47
# File 'app/models/ckeditor/asset.rb', line 45

def self.policy_class
  Georgia::MediaPolicy
end

Instance Method Details

#extensionObject



40
41
42
43
# File 'app/models/ckeditor/asset.rb', line 40

def extension
  self.data_content_type ||= self.data.file.content_type
  @extension ||= data_content_type.gsub(/.*\/(.*)/, '\1')
end

#image?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/models/ckeditor/asset.rb', line 49

def image?
  false
end

#short_nameObject



36
37
38
# File 'app/models/ckeditor/asset.rb', line 36

def short_name
  @short_name ||= self.data.file.filename.dup.gsub(/(.*)\.#{extension}/, '\1') if data.file and data.file.filename
end

#to_jq_uploadObject



26
27
28
29
30
31
32
33
34
# File 'app/models/ckeditor/asset.rb', line 26

def to_jq_upload
  {
    "name" => read_attribute(:data),
    "size" => data.size,
    "url" => data.url,
    "delete_url" => media_path(id: id),
    "delete_type" => "DELETE"
  }
end