Sha256: 5adaee260ff6aa1d0d74bfaea31e7535d931be4295c01398bf0d81cd287add0a

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

module GovukPublishingComponents
  module Presenters
    # @private
    class NavigationType
      GUIDANCE_SCHEMAS =
        %w{answer contact guide detailed_guide document_collection publication}.freeze

      def initialize(content_item)
        @content_item = content_item
      end

      def should_present_taxonomy_navigation?
        !content_is_tagged_to_browse_pages? &&
          content_is_tagged_to_a_live_taxon? &&
          content_schema_is_guidance?
      end

    private

      def content_is_tagged_to_a_live_taxon?
        @content_item.dig("links", "taxons").to_a.any? { |taxon| taxon["phase"] == "live" }
      end

      def content_is_tagged_to_browse_pages?
        @content_item.dig("links", "mainstream_browse_pages").present?
      end

      def content_schema_is_guidance?
        GUIDANCE_SCHEMAS.include? @content_item["schema_name"]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
govuk_publishing_components-6.0.0 lib/govuk_publishing_components/presenters/navigation_type.rb
govuk_publishing_components-5.7.0 lib/govuk_publishing_components/presenters/navigation_type.rb
govuk_publishing_components-5.6.0 lib/govuk_publishing_components/presenters/navigation_type.rb