Sha256: f15cfd20282666f4a39c4a896e4226231a2a32847d54944e401c3ce25a354e92

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true
require 'dato/local/field_type/seo'

module Dato
  module Local
    module FieldType
      class GlobalSeo
        attr_reader :site_name
        attr_reader :title_suffix
        attr_reader :twitter_account
        attr_reader :facebook_page_url

        def self.parse(value, _repo)
          value && new(
            value[:site_name],
            value[:title_suffix],
            value[:twitter_account],
            value[:facebook_page_url],
            value[:fallback_seo]
          )
        end

        def initialize(
          site_name,
          title_suffix,
          twitter_account,
          facebook_page_url,
          fallback_seo
        )
          @site_name = site_name
          @title_suffix = title_suffix
          @twitter_account = twitter_account
          @facebook_page_url = facebook_page_url
          @fallback_seo = fallback_seo
        end

        def fallback_seo
          @fallback_seo && Seo.parse(@fallback_seo, nil)
        end

        def to_hash
          {
            site_name: site_name,
            title_suffix: title_suffix,
            twitter_account: twitter_account,
            facebook_page_url: facebook_page_url,
            fallback_seo: fallback_seo && fallback_seo.to_hash
          }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dato-0.3.6 lib/dato/local/field_type/global_seo.rb
dato-0.3.5 lib/dato/local/field_type/global_seo.rb
dato-0.3.3 lib/dato/local/field_type/global_seo.rb