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



34
35
36
37
38
39
40
41
# File 'lib/ckeditor/orm/base.rb', line 34

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

  super options
end

#as_json_methodsObject



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

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



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

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

#has_dimensions?Boolean

Returns:

  • (Boolean)


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

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

#image?Boolean

Returns:

  • (Boolean)


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

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

#url_contentObject



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

def url_content
  url
end

#url_thumbObject



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

def url_thumb
  url(:thumb)
end