Module: Parliament::Utils::Helpers::RequestHelper
- Defined in:
- lib/parliament/utils/helpers/request_helper.rb
Constant Summary collapse
- NAMESPACE_URI =
The base namespace used for filtering parliamentary data within sparql queries
'https://id.parliament.uk'.freeze
Class Method Summary collapse
-
.filter_response_data(request, *filters) ⇒ Parliament::Response
Takes a Parliament::Request and a optional amount of filters and calls the #get method on on the request.
-
.namespace_uri ⇒ String
Returns the base namespace used for filtering parliamentary data within sparql queries.
-
.namespace_uri_path(path) ⇒ String
Returns uri with specific path added for filtering parliamentary data within sparql queries.
-
.namespace_uri_schema_path(type) ⇒ String
Returns uri with schema path and specific type added for filtering parliamentary data within sparql queries.
-
.process_available_letters(request) ⇒ Array<String>
Takes a Parliament::Request and calls the #get method.
Class Method Details
.filter_response_data(request, *filters) ⇒ Parliament::Response
Takes a Parliament::Request and a optional amount of filters and calls the #get method on on the request. Then calls Parliament::Response#filter with the filters as the parameters on the resulting response.
26 27 28 |
# File 'lib/parliament/utils/helpers/request_helper.rb', line 26 def self.filter_response_data(request, *filters) request.get.filter(*filters) end |
.namespace_uri ⇒ String
Returns the base namespace used for filtering parliamentary data within sparql queries
33 34 35 |
# File 'lib/parliament/utils/helpers/request_helper.rb', line 33 def self.namespace_uri NAMESPACE_URI end |
.namespace_uri_path(path) ⇒ String
Returns uri with specific path added for filtering parliamentary data within sparql queries
42 43 44 |
# File 'lib/parliament/utils/helpers/request_helper.rb', line 42 def self.namespace_uri_path(path) namespace_uri + path end |
.namespace_uri_schema_path(type) ⇒ String
Returns uri with schema path and specific type added for filtering parliamentary data within sparql queries
51 52 53 |
# File 'lib/parliament/utils/helpers/request_helper.rb', line 51 def self.namespace_uri_schema_path(type) namespace_uri_path("/schema/#{type}") end |
.process_available_letters(request) ⇒ Array<String>
Takes a Parliament::Request and calls the #get method. Then maps the #value method on the resulting response.
15 16 17 18 |
# File 'lib/parliament/utils/helpers/request_helper.rb', line 15 def self.process_available_letters(request) response = request.get response.map(&:value) end |