Class: Tenon::AssetDecorator

Inherits:
ApplicationDecorator show all
Defined in:
app/decorators/tenon/asset_decorator.rb

Instance Method Summary collapse

Methods inherited from ApplicationDecorator

#edit_path, #path, #published?, #serializer_class

Instance Method Details

#display_nameObject



15
16
17
18
# File 'app/decorators/tenon/asset_decorator.rb', line 15

def display_name
  name = object.title.blank? ? object.attachment_file_name : object.title
  h.truncate(name, length: 50)
end

#human_sizeObject



11
12
13
# File 'app/decorators/tenon/asset_decorator.rb', line 11

def human_size
  h.number_to_human_size(object.attachment_file_size)
end

#iconObject



3
4
5
# File 'app/decorators/tenon/asset_decorator.rb', line 3

def icon
  h.asset_icon(object)
end

#style_urlsObject



20
21
22
23
24
25
# File 'app/decorators/tenon/asset_decorator.rb', line 20

def style_urls
  styles = object.attachment.styles.map do |key, style|
    [key, object.attachment.url(key)]
  end
  Hash[styles]
end

#tileObject



7
8
9
# File 'app/decorators/tenon/asset_decorator.rb', line 7

def tile
  h.asset_tile(object)
end