Sha256: 10cc727111f794c2c4a3e8e97e001845ed8fea7f79c09dfe5eed893e7af5b8d5

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

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

module Agave
  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

4 entries across 4 versions & 1 rubygems

Version Path
agave-client-0.1.3 lib/agave/local/field_type/global_seo.rb
agave-client-0.1.2 lib/agave/local/field_type/global_seo.rb
agave-client-0.1.1 lib/agave/local/field_type/global_seo.rb
agave-client-0.1.0 lib/agave/local/field_type/global_seo.rb