Sha256: 61675f77ff7ca705a2a1a15080440b97d65079da7a418be75417ad73a5456232

Contents?: true

Size: 1.33 KB

Versions: 45

Compression:

Stored size: 1.33 KB

Contents

module GovukPublishingComponents
  module Presenters
    class Page
      attr_reader :local_assigns

      def initialize(local_assigns)
        @local_assigns = local_assigns
      end

      def schema
        local_assigns.fetch(:schema)
      end

      def canonical_url
        local_assigns[:canonical_url] || (Plek.current.website_root + content_item["base_path"])
      end

      def body
        local_assigns[:body] || content_item.dig("details", "body")
      end

      def title
        local_assigns[:title] || content_item["title"]
      end

      def description
        local_assigns[:description] || content_item["description"]
      end

      def has_image?
        content_item.dig("details", "image").present?
      end

      def image_url
        content_item.dig("details", "image", "high_resolution_url") || content_item.dig("details", "image", "url")
      end

      def image_alt_text
        content_item.dig("details", "image", "alt_text")
      end

      def image_placeholders
        local_assigns[:image_placeholders]
      end

      def document_type
        content_item["document_type"]
      end

      def base_path
        content_item["base_path"]
      end

      def content_item
        local_assigns[:content_item]
      end

      def logo_url
        local_assigns[:logo_url]
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
govuk_publishing_components-20.0.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-19.0.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-18.3.1 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-18.3.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-18.2.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-18.1.2 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-18.1.1 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-18.1.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-18.0.1 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-18.0.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-17.21.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-17.20.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-17.19.1 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-17.19.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-17.18.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-17.17.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-17.16.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-17.15.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-17.14.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-17.13.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb