Class: Qa::AuthorityRequestContext Abstract Private

Inherits:
Object
  • Object
show all
Defined in:
lib/qa/authority_request_context.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class is abstract.
Note:

THIS IS NOT TESTED NOR EXERCISED CODE IT IS PROVIDED AS CONJECTURE. FUTURE CHANGES MIGHT BUILD AND REFACTOR UPON THIS.

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 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.

Constant Summary collapse

SEARCH_HEADER_KEYS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[request request_id subauthority user_language performance_data context response_header replacements].freeze
FETCH_HEADER_KEYS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[request request_id subauthority user_language performance_data format response_header replacements].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params: {}, headers: {}, **kwargs) ⇒ AuthorityRequestContext

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AuthorityRequestContext.



23
24
25
26
27
28
29
# 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

Instance Attribute Details

#headersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
# File 'lib/qa/authority_request_context.rb', line 34

def headers
  @headers
end

#paramsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
# File 'lib/qa/authority_request_context.rb', line 34

def params
  @params
end

Class Method Details

.fallbackObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/qa/authority_request_context.rb', line 19

def self.fallback
  new
end

Instance Method Details

#fetch_headerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
46
47
# 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

#search_headerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
40
41
# 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