Class: Locomotive::ThemeAssetPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/locomotive/theme_asset_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

#ability, #depth

Instance Method Summary collapse

Methods inherited from BasePresenter

#ability?, #after_initialize, getters_to_hash, #id, setters_to_hash, #site

Methods included from Presentable

#after_initialize, #as_json, #attributes=, #getters, #initialize, #property_options, #setters

Instance Method Details

#can_be_deletedObject



43
44
45
# File 'app/presenters/locomotive/theme_asset_presenter.rb', line 43

def can_be_deleted
  self.ability.try(:can?, :destroy, self.source)
end

#content_typeObject

properties ##



6
# File 'app/presenters/locomotive/theme_asset_presenter.rb', line 6

properties  :content_type,  :folder

#dimensionsObject



35
36
37
# File 'app/presenters/locomotive/theme_asset_presenter.rb', line 35

def dimensions
  self.source.image? ? "#{self.source.width}px x #{self.source.height}px" : nil
end

#local_pathObject

other getters / setters ##



19
20
21
# File 'app/presenters/locomotive/theme_asset_presenter.rb', line 19

def local_path
  self.source.local_path(true)
end

#plain_textObject



47
48
49
# File 'app/presenters/locomotive/theme_asset_presenter.rb', line 47

def plain_text
  plain_text? ? self.source.plain_text : nil
end

#raw_sizeObject



31
32
33
# File 'app/presenters/locomotive/theme_asset_presenter.rb', line 31

def raw_size
  self.source.size
end

#sizeObject



27
28
29
# File 'app/presenters/locomotive/theme_asset_presenter.rb', line 27

def size
  number_to_human_size(self.source.size)
end

#updated_atObject



39
40
41
# File 'app/presenters/locomotive/theme_asset_presenter.rb', line 39

def updated_at
  I18n.l(self.source.updated_at, :format => :short)
end

#urlObject



23
24
25
# File 'app/presenters/locomotive/theme_asset_presenter.rb', line 23

def url
  self.source.source.url
end