Class: Qa::LinkedData::RequestHeaderService
- Inherits:
-
Object
- Object
- Qa::LinkedData::RequestHeaderService
- Defined in:
- app/services/qa/linked_data/request_header_service.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #content_type_for_format ⇒ Object
-
#fetch_header ⇒ Object
Construct request parameters to pass to fetching a term (linked data module).
-
#initialize(request:, params:) ⇒ RequestHeaderService
constructor
A new instance of RequestHeaderService.
-
#search_header ⇒ Object
Construct request parameters to pass to search_query (linked data module).
Constructor Details
#initialize(request:, params:) ⇒ RequestHeaderService
Note:
params may have additional attribute-value pairs that are passed through via replacements (only configured replacements are used)
Returns a new instance of RequestHeaderService.
16 17 18 19 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 16 def initialize(request:, params:) @request = request @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 5 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
5 6 7 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 5 def request @request end |
Instance Method Details
#content_type_for_format ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 50 def content_type_for_format case format when 'jsonld' 'application/ld+json' when 'n3' 'text/n3' when 'ntriples' 'application/n-triples' else 'application/json' end end |
#fetch_header ⇒ Object
Construct request parameters to pass to fetching a term (linked data module).
38 39 40 41 42 43 44 45 46 47 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 38 def fetch_header header = {} header[:subauthority] = params.fetch(:subauthority, nil) header[:user_language] = user_language header[:performance_data] = performance_data? header[:format] = format header[:response_header] = response_header? header[:replacements] = replacements header end |
#search_header ⇒ Object
Construct request parameters to pass to search_query (linked data module).
24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 24 def search_header header = {} header[:subauthority] = params.fetch(:subauthority, nil) header[:user_language] = user_language header[:performance_data] = performance_data? header[:context] = context? header[:response_header] = response_header? header[:replacements] = replacements header end |