Class: Qa::AuthorityRequestContext Abstract Private
- Inherits:
-
Object
- Object
- Qa::AuthorityRequestContext
- 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 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
- #headers ⇒ Object private
- #params ⇒ Object private
Class Method Summary collapse
- .fallback ⇒ Object private
Instance Method Summary collapse
- #fetch_header ⇒ Object private
-
#initialize(params: {}, headers: {}, **kwargs) ⇒ AuthorityRequestContext
constructor
private
A new instance of AuthorityRequestContext.
- #search_header ⇒ Object private
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
#headers ⇒ Object
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 |
#params ⇒ Object
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
.fallback ⇒ Object
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_header ⇒ Object
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_header ⇒ Object
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 |