class GovukPublishingComponents::Presenters::ContentBreadcrumbsBasedOnTopic

Attributes

content_item[R]

Public Class Methods

call(content_item) click to toggle source
# File lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb, line 4
def self.call(content_item)
  new(content_item).breadcrumbs
end
new(content_item) click to toggle source
# File lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb, line 10
def initialize(content_item)
  @content_item = content_item
end

Public Instance Methods

breadcrumbs() click to toggle source
first_topic() click to toggle source
# File lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb, line 29
def first_topic
  topics.first
end
topic_breadcrumb() click to toggle source
# File lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb, line 22
def topic_breadcrumb
  {
    title: first_topic["title"],
    url: first_topic["base_path"],
  }
end
topics() click to toggle source
# File lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb, line 33
def topics
  @topics ||= content_item.dig("links", "topics")
end