Sha256: be37696d9ec44e6a7299d7de45af5b3712b7f113f3edeb7e803d30b099412891

Contents?: true

Size: 1.13 KB

Versions: 36

Compression:

Stored size: 1.13 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", "url")
      end

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

      def image_placeholders
        local_assigns[:image_placeholders]
      end

      def content_item
        local_assigns[:content_item]
      end

      def logo_url
        local_assigns[:logo_url]
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
govuk_publishing_components-12.2.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-12.1.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-12.0.1 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-12.0.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-11.2.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-11.1.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-11.0.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-10.2.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-10.1.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-10.0.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-9.28.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-9.27.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-9.26.1 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-9.26.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-9.25.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-9.24.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-9.23.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-9.22.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-9.21.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb
govuk_publishing_components-9.20.0 lib/govuk_publishing_components/presenters/machine_readable/page.rb