Class: Locomotive::EditableFilePresenter

Inherits:
EditableElementPresenter show all
Defined in:
app/presenters/locomotive/editable_file_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

#__ability, #__depth

Instance Method Summary collapse

Methods inherited from EditableElementPresenter

#block_name, #label, #slug, #type

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

Methods included from Presentable

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

Instance Method Details

#filenameObject

other getters / setters ##



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

def filename
  self.content ? File.basename(self.content) : nil
end

#source=(value) ⇒ Object



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

def source=(value)
  self.__source.source = value
end

#source_url=(url) ⇒ Object



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

def source_url=(url)
  self.__source.remote_source_url = url
end

#trueObject

properties ##



6
7
8
9
10
# File 'app/presenters/locomotive/editable_file_presenter.rb', line 6

with_options only_getter: true do |presenter|
  presenter.property  :content, description: 'The default url if no uploaded file'
  presenter.property  :url, description: 'Alias for content'
  presenter.property  :filename
end

#urlObject



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

def url
  self.content
end