app/presenters/locomotive/site_presenter.rb in locomotive_cms-2.0.0.rc12 vs app/presenters/locomotive/site_presenter.rb in locomotive_cms-2.0.0

- old
+ new

@@ -1,24 +1,39 @@ module Locomotive class SitePresenter < BasePresenter - delegate :name, :locales, :subdomain, :domains, :robots_txt, :seo_title, :meta_keywords, :meta_description, :domains_without_subdomain, :to => :source + ## properties ## + property :name + properties :locales, type: Array + + with_options if: Proc.new { Locomotive.config.multi_sites_or_manage_domains? } do |presenter| + presenter.property :subdomain + presenter.property :domains, type: Array, required: false + end + + with_options only_getter: true do |presenter| + presenter.property :domains_without_subdomain, type: Array, if: Proc.new { Locomotive.config.multi_sites_or_manage_domains? } + presenter.property :domain_name + presenter.property :memberships, type: Array + end + + properties :seo_title, :meta_keywords, :meta_description, :robots_txt, required: false + + ## other getters / setters ## + def domain_name Locomotive.config.domain end def memberships - self.source.memberships.map { |membership| membership.as_json(self.options) } + self.__source.memberships.map { |membership| membership.as_json(self.__options) } end - def included_methods - super + %w(name locales domain_name subdomain domains robots_txt seo_title meta_keywords meta_description domains_without_subdomain memberships) - end + ## custom as_json ## def as_json_for_html_view - methods = included_methods.clone - %w(memberships) - self.as_json(methods) + self.as_json(self.getters - %w(memberships)) end end -end \ No newline at end of file +end