class Locomotive::Wagon::PageDecorator
Attributes
__content_assets_pusher__[RW]
__persist_content__[RW]
Public Class Methods
new(object, locale, content_assets_pusher, persist_content)
click to toggle source
Calls superclass method
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 11 def initialize(object, locale, content_assets_pusher, persist_content) self.__content_assets_pusher__ = content_assets_pusher self.__persist_content__ = persist_content super(object, locale, nil) # we don't need a fallback to the default locale end
Public Instance Methods
__attributes__()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 17 def __attributes__ _attributes = %i(title slug parent handle response_type published position listed is_layout allow_layout redirect_url redirect_type seo_title meta_keywords meta_description editable_elements sections_dropzone_content sections_content content_type template display_settings) # remove the attributes that end-users might have modified in the back-office if persisted? && !__persist_content__ _attributes -= %i(title published listed position seo_title meta_keywords meta_description editable_elements sections_dropzone_content sections_content) end # no need to update the slug if this is for an update # in case of a localized site, if this is a new page, the _id will remain empty # for the other locales. _attributes -= %i(slug) if persisted? _attributes end
_id()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 48 def _id __getobj__[:remote_id] end
_id=(id)
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 44 def _id=(id) __getobj__[:remote_id] = id end
allow_layout()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 60 def allow_layout self[:allow_layout] end
content_type()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 76 def content_type templatized? ? content_type_id : nil end
display_settings()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 72 def display_settings self[:display_settings] end
editable_elements()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 80 def editable_elements return nil if __getobj__.editable_elements.all.count == 0 __getobj__.editable_elements.all.map do |element| EditableElementDecorator.new(element, __locale__, __content_assets_pusher__) end end
folder_path()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 100 def folder_path *segments, slug = fullpath.split('/') segments.join('/') end
is_layout()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 52 def is_layout if self[:is_layout].nil? !(__getobj__._fullpath =~ %r(^layouts/)).nil? else self[:is_layout] end end
parent()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 68 def parent self[:parent] end
response_type()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 64 def response_type self[:response_type] end
sections_content()
click to toggle source
Calls superclass method
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 92 def sections_content replace_with_content_assets!(super&.to_json) end
sections_dropzone_content()
click to toggle source
Calls superclass method
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 88 def sections_dropzone_content replace_with_content_assets!(super&.to_json) end
template()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 96 def template replace_with_content_assets!(self.liquid_source) end
Private Instance Methods
persisted?()
click to toggle source
# File lib/locomotive/wagon/decorators/page_decorator.rb, line 107 def persisted? self._id.present? end