Class: GovukPublishingComponents::AppHelpers::TaxonBreadcrumbs::ContentItem

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content_item) ⇒ ContentItem

Returns a new instance of ContentItem.



50
51
52
# File 'lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb', line 50

def initialize(content_item)
  @content_item = content_item
end

Instance Attribute Details

#content_itemObject (readonly)

Returns the value of attribute content_item.



48
49
50
# File 'lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb', line 48

def content_item
  @content_item
end

Instance Method Details

#base_pathObject



70
71
72
# File 'lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb', line 70

def base_path
  content_item.fetch("base_path")
end

#parent_taxonObject



54
55
56
57
58
59
60
# File 'lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb', line 54

def parent_taxon
  @parent_taxon ||= begin
    parent_content_item = content_item.dig("links", "parent_taxons", 0)

    ContentItem.new(parent_content_item) unless parent_content_item.nil?
  end
end

#phase_is_live?(taxon) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb', line 62

def phase_is_live?(taxon)
  taxon["phase"] == "live"
end

#titleObject



66
67
68
# File 'lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb', line 66

def title
  content_item.fetch("title")
end