Sha256: 89985de24dfedd0b9ed6fb6e6147be437e1e3266a8d0519b87d51e9f33289671

Contents?: true

Size: 1.51 KB

Versions: 7

Compression:

Stored size: 1.51 KB

Contents

module Locomotive::Steam

  class Site

    include Locomotive::Steam::Models::Entity

    def initialize(attributes = {})
      super({
        cache_enabled:            false,
        cache_control:            nil,
        cache_vary:               nil,
        bypass_browser_locale:    false,
        prefix_default_locale:    false,
        updated_at:               nil,
        content_version:          nil,
        template_version:         nil,
        domains:                  [],
        redirect_to_first_domain: false,
        redirect_to_https:        false,
        url_redirections:         [],
        private_access:           false,
        password:                 nil,
        metafields_schema:        {},
        metafields:               nil,
        sections:                 nil,
        sections_content:         nil,
        asset_host:               nil,
        routes:                   []
      }.merge(attributes))
    end

    def handle
      self[:handle] || self[:subdomain]
    end

    def default_locale
      locales.first || :en
    end

    def locales
      (self[:locales] || [:en]).map(&:to_sym)
    end

    def timezone_name
      self[:timezone] || self[:timezone_name] || 'UTC'
    end

    def timezone
      @timezone ||= ActiveSupport::TimeZone.new(timezone_name)
    end

    def last_modified_at
      [self.content_version, self.template_version].compact.sort.last || self.updated_at
    end

    def to_liquid
      Locomotive::Steam::Liquid::Drops::Site.new(self)
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/entities/site.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/entities/site.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/entities/site.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/entities/site.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/entities/site.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/entities/site.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/entities/site.rb