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

#_id, #ability?, #after_initialize, #errors, #formatted_time, getters_or_setters_to_hash, getters_to_hash, #html_view?, #include_errors?, setters_to_hash, #site, #true

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, :checksum

#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