Class: Locomotive::PagePresenter
- Inherits:
-
BasePresenter
- Object
- BasePresenter
- Locomotive::PagePresenter
- Defined in:
- app/presenters/locomotive/page_presenter.rb
Instance Attribute Summary
Attributes inherited from BasePresenter
Instance Method Summary collapse
-
#as_json_for_html_view ⇒ Object
custom as_json ##.
- #editable_elements=(elements) ⇒ Object
-
#escaped_raw_template ⇒ Object
other getters / setters ##.
- #localized_fullpaths ⇒ Object
- #parent_fullpath=(fullpath) ⇒ Object
-
#title ⇒ Object
properties / collections ##.
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
#as_json_for_html_view ⇒ Object
custom as_json ##
53 54 55 |
# File 'app/presenters/locomotive/page_presenter.rb', line 53 def as_json_for_html_view self.as_json(self.getters - %w(raw_template)) end |
#editable_elements=(elements) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/presenters/locomotive/page_presenter.rb', line 37 def editable_elements=(elements) self.source.force_serialize_template # initialize the default editable_elements elements.each do |attributes| block, slug = attributes.delete(:block), attributes.delete(:slug) block = nil if block.blank? # change empty string in block to nil if element = self.source.find_editable_element(block, slug) element.from_presenter(attributes) end end end |
#escaped_raw_template ⇒ Object
other getters / setters ##
21 22 23 |
# File 'app/presenters/locomotive/page_presenter.rb', line 21 def escaped_raw_template h(self.source.raw_template) end |
#localized_fullpaths ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/presenters/locomotive/page_presenter.rb', line 25 def localized_fullpaths {}.tap do |hash| self.site.locales.each do |locale| hash[locale] = self.site.localized_page_fullpath(self.source, locale) end end end |
#parent_fullpath=(fullpath) ⇒ Object
33 34 35 |
# File 'app/presenters/locomotive/page_presenter.rb', line 33 def parent_fullpath=(fullpath) self.source.parent = self.site.pages.where(:fullpath => fullpath).first end |
#title ⇒ Object
properties / collections ##
6 |
# File 'app/presenters/locomotive/page_presenter.rb', line 6 properties :title, :slug, :handle, :position, :response_type, :cache_strategy, :raw_template |