Class: Ckeditor::Asset

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Orm::ActiveRecord::AssetBase, Georgia::Concerns::Taggable, Georgia::Indexer::Adapter
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
}

Instance Method Summary collapse

Methods included from Georgia::Indexer::Adapter

included, load_extension

Instance Method Details

#extensionObject



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

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

#short_nameObject



32
33
34
# File 'app/models/ckeditor/asset.rb', line 32

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

#to_jq_uploadObject



22
23
24
25
26
27
28
29
30
# File 'app/models/ckeditor/asset.rb', line 22

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