Class: GovukPublishingComponents::Presenters::MetaTags

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_publishing_components/presenters/meta_tags.rb

Constant Summary collapse

FORMATS_THAT_MIGHT_INCLUDE_POSTCODES =
%w[smart_answer finder local_transaction place special_route transaction].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content_item, local_assigns, request) ⇒ MetaTags

Returns a new instance of MetaTags.



8
9
10
11
12
13
14
15
16
17
# File 'lib/govuk_publishing_components/presenters/meta_tags.rb', line 8

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

Instance Attribute Details

#content_itemObject (readonly)

Returns the value of attribute content_item.



6
7
8
# File 'lib/govuk_publishing_components/presenters/meta_tags.rb', line 6

def content_item
  @content_item
end

#detailsObject (readonly)

Returns the value of attribute details.



6
7
8
# File 'lib/govuk_publishing_components/presenters/meta_tags.rb', line 6

def details
  @details
end

Returns the value of attribute links.



6
7
8
# File 'lib/govuk_publishing_components/presenters/meta_tags.rb', line 6

def links
  @links
end

#local_assignsObject (readonly)

Returns the value of attribute local_assigns.



6
7
8
# File 'lib/govuk_publishing_components/presenters/meta_tags.rb', line 6

def local_assigns
  @local_assigns
end

#requestObject (readonly)

Returns the value of attribute request.



6
7
8
# File 'lib/govuk_publishing_components/presenters/meta_tags.rb', line 6

def request
  @request
end

Instance Method Details

#meta_tagsObject



19
20
21
22
23
24
25
26
27
# File 'lib/govuk_publishing_components/presenters/meta_tags.rb', line 19

def meta_tags
  meta_tags = {}
  meta_tags = add_core_tags(meta_tags)
  meta_tags = add_ga4_political_tags(meta_tags)
  meta_tags = add_organisation_tags(meta_tags)
  meta_tags = add_political_tags(meta_tags)
  meta_tags = add_taxonomy_tags(meta_tags)
  add_step_by_step_tags(meta_tags)
end