Sha256: d4e31d23de29cb49d84a1a07ca7cc8efdd40744d272d91d59cecb7dc1574e26e

Contents?: true

Size: 1.37 KB

Versions: 26

Compression:

Stored size: 1.37 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],
            repo
          )
        end

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

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

        def to_hash(*args)
          {
            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(*args)
          }
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
dato-0.8.0 lib/dato/local/field_type/global_seo.rb
dato-0.7.18 lib/dato/local/field_type/global_seo.rb
dato-0.7.17 lib/dato/local/field_type/global_seo.rb
dato-0.7.16 lib/dato/local/field_type/global_seo.rb
dato-0.7.15 lib/dato/local/field_type/global_seo.rb
dato-0.7.14 lib/dato/local/field_type/global_seo.rb
dato-0.7.13 lib/dato/local/field_type/global_seo.rb
dato-0.7.10 lib/dato/local/field_type/global_seo.rb
dato-0.7.9 lib/dato/local/field_type/global_seo.rb
dato-0.7.8 lib/dato/local/field_type/global_seo.rb
dato-0.7.7 lib/dato/local/field_type/global_seo.rb
dato-0.7.6 lib/dato/local/field_type/global_seo.rb
dato-0.7.5 lib/dato/local/field_type/global_seo.rb
dato-0.7.4 lib/dato/local/field_type/global_seo.rb
dato-0.7.3 lib/dato/local/field_type/global_seo.rb
dato-0.7.2 lib/dato/local/field_type/global_seo.rb
dato-0.7.1 lib/dato/local/field_type/global_seo.rb
dato-0.7.0 lib/dato/local/field_type/global_seo.rb
dato-0.6.18 lib/dato/local/field_type/global_seo.rb
dato-0.6.17 lib/dato/local/field_type/global_seo.rb