Sha256: c56c3200e6dcabef37ca6f16387f7f38091a24344e2eed0d021507d53544ad94

Contents?: true

Size: 821 Bytes

Versions: 3

Compression:

Stored size: 821 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 && UploadId.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

3 entries across 3 versions & 1 rubygems

Version Path
dato-0.8.3 lib/dato/local/field_type/seo.rb
dato-0.8.2 lib/dato/local/field_type/seo.rb
dato-0.8.1 lib/dato/local/field_type/seo.rb