Class: Qa::IriTemplate::UrlConfig
- Inherits:
-
Object
- Object
- Qa::IriTemplate::UrlConfig
- Defined in:
- app/models/qa/iri_template/url_config.rb
Constant Summary collapse
- TYPE =
"IriTemplate".freeze
- CONTEXT =
"http://www.w3.org/ns/hydra/context.jsonld".freeze
Instance Attribute Summary collapse
-
#mapping ⇒ Object
readonly
- Array<Qa::IriTempalte::VariableMap>
-
array of maps for use with a template (required).
-
#template ⇒ Object
readonly
- String
-
the URL template with variables for substitution (required).
-
#variable_representation ⇒ Object
readonly
- String
-
always “BasicRepresentation” # TODO what other values are supported and what do they mean.
Instance Method Summary collapse
-
#extract_substitutions(substitutions) ⇒ HashWithIndifferentAccess
Selective extract substitution variable-value pairs from the provided substitutions.
-
#initialize(url_config) ⇒ UrlConfig
constructor
A new instance of UrlConfig.
Constructor Details
#initialize(url_config) ⇒ UrlConfig
Returns a new instance of UrlConfig.
17 18 19 20 21 22 |
# File 'app/models/qa/iri_template/url_config.rb', line 17 def initialize(url_config) @url_config = url_config @template = Qa::LinkedData::Config::Helper.fetch_required(url_config, :template, nil) @mapping = extract_mapping @variable_representation = Qa::LinkedData::Config::Helper.fetch(url_config, :variable_representation, 'BasicRepresentation') end |
Instance Attribute Details
#mapping ⇒ Object (readonly)
- Array<Qa::IriTempalte::VariableMap>
-
array of maps for use with a template (required)
11 12 13 |
# File 'app/models/qa/iri_template/url_config.rb', line 11 def mapping @mapping end |
#template ⇒ Object (readonly)
- String
-
the URL template with variables for substitution (required)
9 10 11 |
# File 'app/models/qa/iri_template/url_config.rb', line 9 def template @template end |
#variable_representation ⇒ Object (readonly)
- String
-
always “BasicRepresentation” # TODO what other values are supported and what do they mean
10 11 12 |
# File 'app/models/qa/iri_template/url_config.rb', line 10 def variable_representation @variable_representation end |
Instance Method Details
#extract_substitutions(substitutions) ⇒ HashWithIndifferentAccess
Selective extract substitution variable-value pairs from the provided substitutions.
27 28 29 30 31 32 33 |
# File 'app/models/qa/iri_template/url_config.rb', line 27 def extract_substitutions(substitutions) selected_substitutions = HashWithIndifferentAccess.new mapping.each do |m| selected_substitutions[m.variable] = substitutions[m.variable] if substitutions.key? m.variable end selected_substitutions end |