Module: Slimmer::Headers

Defined in:
lib/slimmer/headers.rb

Instance Method Summary collapse

Instance Method Details

#set_slimmer_headers(hash) ⇒ Object

Set the "slimmer headers" to configure the page

Parameters:

  • hash (Hash)

    the options

Options Hash (hash):

  • application_name (String)
  • format (String)
  • organisations (String)
  • page_owner (String)
  • remove_search (String)
  • report_a_problem (String)
  • result_count (String)
  • search_parameters (String)
  • section (String)
  • skip (String)
  • template (String)
  • world_locations (String)

Raises:

  • (InvalidHeader)

77
78
79
80
81
82
83
# File 'lib/slimmer/headers.rb', line 77

def set_slimmer_headers(hash)
  raise InvalidHeader if (hash.keys - SLIMMER_HEADER_MAPPING.keys).any?
  SLIMMER_HEADER_MAPPING.each do |hash_key, header_suffix|
    value = hash[hash_key]
    headers["#{HEADER_PREFIX}-#{header_suffix}"] = value.to_s if value
  end
end