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 ⇒ Object
- #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
#_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
#as_json_for_html_view ⇒ Object
custom as_json ##
77 78 79 |
# File 'app/presenters/locomotive/page_presenter.rb', line 77 def as_json_for_html_view self.as_json(self.getters - %w(raw_template)) end |
#editable_elements ⇒ Object
57 58 59 |
# File 'app/presenters/locomotive/page_presenter.rb', line 57 def editable_elements self.__source.enabled_editable_elements.map(&:as_json) end |
#editable_elements=(elements) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/presenters/locomotive/page_presenter.rb', line 61 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 ##
41 42 43 |
# File 'app/presenters/locomotive/page_presenter.rb', line 41 def escaped_raw_template h(self.__source.raw_template) end |
#localized_fullpaths ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/presenters/locomotive/page_presenter.rb', line 45 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
53 54 55 |
# File 'app/presenters/locomotive/page_presenter.rb', line 53 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 |