Sha256: 74bcb97369d49227b7bd7b073838dcc4a95adb4e1a65537ce0a0e89628477721

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 Bytes

Contents

# frozen_string_literal: true
module Dato
  module Local
    module FieldType
      class Seo
        attr_reader :title, :description, :twitter_card

        def self.parse(value, repo)
          value && new(value[:title], value[:description], value[:image], value[:twitter_card], repo)
        end

        def initialize(title, description, image, twitter_card, repo)
          @title = title
          @description = description
          @image = image
          @repo = repo
          @twitter_card = twitter_card
        end

        def image
          @image && File.parse(@image, @repo)
        end

        def to_hash(*args)
          {
            title: title,
            description: description,
            image: image && image.to_hash(*args)
          }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dato-0.6.9 lib/dato/local/field_type/seo.rb