class Qa::AuthorityRequestContext
@note THIS IS NOT TESTED NOR EXERCISED CODE IT IS PROVIDED AS CONJECTURE. FUTURE CHANGES MIGHT
BUILD AND REFACTOR UPON THIS.
@api private @abstract
This class is responsible for exposing methods that are required by both linked data and non-linked data authorities. As of v5.10.0, those three methods are: params, search_header
, fetch_header. Those are the methods that are used in {Qa::LinkedData::RequestHeaderService} and in {Qa::Authorities::Discogs::GenericAuthority}.
The intention is to provide a class that can behave like a controller object without being that entire controller object.
@see Qa::LinkedData::RequestHeaderService @see Qa::Authorities::Discogs::GenericAuthority
Constants
- FETCH_HEADER_KEYS
- SEARCH_HEADER_KEYS
Attributes
Public Class Methods
Source
# File lib/qa/authority_request_context.rb, line 23 def initialize(params: {}, headers: {}, **kwargs) @params = params @headers = headers (SEARCH_HEADER_KEYS + FETCH_HEADER_KEYS).uniq.each do |key| send("#{key}=", kwargs[key]) if kwargs.key?(key) end end
Public Instance Methods
Source
# File lib/qa/authority_request_context.rb, line 43 def fetch_header FETCH_HEADER_KEYS.each_with_object(headers.deep_dup) do |key, header| header[key] = send(key) if send(key).present? end.compact end
Source
# File lib/qa/authority_request_context.rb, line 37 def search_header SEARCH_HEADER_KEYS.each_with_object(headers.deep_dup) do |key, header| header[key] = send(key) if send(key).present? end.compact end