class GovukPublishingComponents::Presenters::MetaTags
Attributes
content_item[R]
details[R]
links[R]
local_assigns[R]
request[R]
Public Class Methods
new(content_item, local_assigns, request)
click to toggle source
# File lib/govuk_publishing_components/presenters/meta_tags.rb, line 6 def initialize(content_item, local_assigns, request) # We have to call deep_symbolize_keys because we're often dealing with a # parsed JSON document which will have string keys by default, but our # components use symbol keys and we want consistency. @content_item = content_item.to_h.deep_symbolize_keys @details = @content_item[:details] || {} @links = @content_item[:links] || {} @local_assigns = local_assigns @request = request end
Public Instance Methods
Private Instance Methods
has_content_history?()
click to toggle source
# File lib/govuk_publishing_components/presenters/meta_tags.rb, line 150 def has_content_history? (content_item[:public_updated_at] && details[:first_public_at] && content_item[:public_updated_at] != details[:first_public_at]) || (details[:change_history] && details[:change_history].size > 1) end
priority_brexit_taxon()
click to toggle source
# File lib/govuk_publishing_components/presenters/meta_tags.rb, line 146 def priority_brexit_taxon priority_taxon_helper.priority_brexit_taxon end
priority_taxon()
click to toggle source
# File lib/govuk_publishing_components/presenters/meta_tags.rb, line 142 def priority_taxon priority_taxon_helper.priority_taxon end
priority_taxon_helper()
click to toggle source
# File lib/govuk_publishing_components/presenters/meta_tags.rb, line 138 def priority_taxon_helper @priority_taxon_helper ||= ContentBreadcrumbsBasedOnPriority.new(content_item.deep_stringify_keys, request.query_parameters) end
root_taxon_slugs(content_item)
click to toggle source
# File lib/govuk_publishing_components/presenters/meta_tags.rb, line 155 def root_taxon_slugs(content_item) root_taxon_set = Set.new links = content_item[:links] # Taxons will have :parent_taxons, but content items will have :taxons parent_taxons = links[:parent_taxons] || links[:taxons] unless links.nil? if parent_taxons.blank? root_taxon_set << content_item[:base_path].sub(%r{^/}, "") if content_item[:document_type] == "taxon" else parent_taxons.each do |parent_taxon| root_taxon_set += root_taxon_slugs(parent_taxon) end end root_taxon_set end
should_strip_dates_pii?(content_item, local_assigns)
click to toggle source
# File lib/govuk_publishing_components/presenters/meta_tags.rb, line 173 def should_strip_dates_pii?(content_item, local_assigns) # allow override if we explicitly want to strip pii (or not) regardless of # document_type return local_assigns[:strip_dates_pii] if local_assigns.key?(:strip_dates_pii) formats_that_might_include_dates = %w[smart_answer] formats_that_might_include_dates.include?(content_item[:document_type]) end
should_strip_postcode_pii?(content_item, local_assigns)
click to toggle source
# File lib/govuk_publishing_components/presenters/meta_tags.rb, line 182 def should_strip_postcode_pii?(content_item, local_assigns) # allow override if we explicitly want to strip pii (or not) regardless of # document_type return local_assigns[:strip_postcode_pii] if local_assigns.key?(:strip_postcode_pii) formats_that_might_include_postcodes = %w[smart_answer finder] formats_that_might_include_postcodes.include?(content_item[:document_type]) end
tagged_to_priority_taxon?()
click to toggle source
# File lib/govuk_publishing_components/presenters/meta_tags.rb, line 134 def tagged_to_priority_taxon? priority_taxon_helper.priority_taxon.present? end