class GovukPublishingComponents::Presenters::PotentialSearchActionSchema

Constants

BASE_SEARCH_URL

Attributes

description[R]
facet_params[R]

Public Class Methods

new(facet_params, description) click to toggle source
# File lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb, line 10
def initialize(facet_params, description)
  @facet_params = facet_params
  @description = description
end

Public Instance Methods

structured_data() click to toggle source
# File lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb, line 15
def structured_data
  # http://schema.org/SearchAction - minimal
  {
    "potentialAction" => {
      "@type": "SearchAction",
      "description": description,
      "target": search_template,
      "query": "required",
    },
  }
end

Private Instance Methods

search_template() click to toggle source
# File lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb, line 29
def search_template
  "#{BASE_SEARCH_URL}&#{facet_params.to_query}"
end