Sha256: d942ccd843ff7d93f0a059e7bd6d11c56007d40b0025f070daf7c4177d34623f

Contents?: true

Size: 1.21 KB

Versions: 17

Compression:

Stored size: 1.21 KB

Contents

module Locomotive
  class SitePresenter < BasePresenter

    ## properties ##

    property    :name
    properties  :locales,       type: Array
    property    :timezone

    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 timezone
      self.__source.timezone_name
    end

    def timezone=(timezone)
      self.__source.timezone_name = timezone
    end

    def memberships
      self.__source.memberships.map { |membership| membership.as_json(self.__options) }
    end

    ## custom as_json ##

    def as_json_for_html_view
      self.as_json(self.getters - %w(memberships))
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
locomotive_cms-2.5.7 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.6 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.6.rc2 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.6.rc1 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.5 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.4 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.3 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.2 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.1 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.0 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.0.rc3 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.0.rc2 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.5.0.rc1 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.4.1 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.4.0 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.3.1 app/presenters/locomotive/site_presenter.rb
locomotive_cms-2.3.0 app/presenters/locomotive/site_presenter.rb