Module: Ckeditor::Orm::Base::AssetBase::InstanceMethods

Defined in:
lib/ckeditor/orm/base.rb

Instance Method Summary collapse

Instance Method Details

#as_json(options = nil) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/ckeditor/orm/base.rb', line 38

def as_json(options = nil)
  options = {
    :methods => as_json_methods,
    :root => "asset"
  }.merge(options || {})

  super options
end

#as_json_methodsObject



34
35
36
# File 'lib/ckeditor/orm/base.rb', line 34

def as_json_methods
  [:url_content, :url_thumb, :size, :filename, :format_created_at]
end

#filenameObject



6
7
8
# File 'lib/ckeditor/orm/base.rb', line 6

def filename
  data_file_name
end

#format_created_atObject



22
23
24
# File 'lib/ckeditor/orm/base.rb', line 22

def format_created_at
  self.created_at.strftime("%d.%m.%Y")
end

#has_dimensions?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/ckeditor/orm/base.rb', line 14

def has_dimensions?
  respond_to?(:width) && respond_to?(:height)
end

#image?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ckeditor/orm/base.rb', line 18

def image?
  Ckeditor::IMAGE_TYPES.include?(data_content_type)
end

#sizeObject



10
11
12
# File 'lib/ckeditor/orm/base.rb', line 10

def size
  data_file_size
end

#url_contentObject



26
27
28
# File 'lib/ckeditor/orm/base.rb', line 26

def url_content
  url
end

#url_thumbObject



30
31
32
# File 'lib/ckeditor/orm/base.rb', line 30

def url_thumb
  url(:thumb)
end