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



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

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

  super(options)
end

#as_json_methods ⇒ Object



36
37
38
# File 'lib/ckeditor/orm/base.rb', line 36

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

#filename ⇒ Object



8
9
10
# File 'lib/ckeditor/orm/base.rb', line 8

def filename
  data_file_name
end

#format_created_at ⇒ Object



24
25
26
# File 'lib/ckeditor/orm/base.rb', line 24

def format_created_at
  I18n.l(created_at, format: :short)
end

#has_dimensions? ⇒ Boolean

Returns:



16
17
18
# File 'lib/ckeditor/orm/base.rb', line 16

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

#image? ⇒ Boolean

Returns:



20
21
22
# File 'lib/ckeditor/orm/base.rb', line 20

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

#size ⇒ Object



12
13
14
# File 'lib/ckeditor/orm/base.rb', line 12

def size
  data_file_size
end

#url_content ⇒ Object



28
29
30
# File 'lib/ckeditor/orm/base.rb', line 28

def url_content
  url
end

#url_thumb ⇒ Object



32
33
34
# File 'lib/ckeditor/orm/base.rb', line 32

def url_thumb
  url(:thumb)
end