Class: Locomotive::PagePresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/locomotive/page_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

#as_json_for_html_viewObject

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_templateObject

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_fullpathsObject



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

#titleObject

properties / collections ##



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

properties  :title, :slug, :handle, :position, :response_type, :cache_strategy, :raw_template