Method: Qa::IriTemplate::VariableMap#initialize

Defined in:
app/models/qa/iri_template/variable_map.rb

#initialize(variable_map) ⇒ VariableMap

Returns a new instance of VariableMap.

Parameters:

  • variable_map (Hash)

    configuration hash for the variable map

Options Hash (variable_map):

  • :variable (String) — default: required

    name of the variable in the template (e.g. ?query has the name ‘query’)

  • :property (String) — default: optional

    always “hydra:freetextQuery” # TODO what other values are supported and what do they mean

  • :required (Boolean) — default: required

    is this variable required

  • :default (String) — default: optional

    value to use if a value is not provided in the request (default: ”)

  • :encode (Boolean) — default: optional

    whether to url_encode the value (default: false)



19
20
21
22
23
24
25
# File 'app/models/qa/iri_template/variable_map.rb', line 19

def initialize(variable_map)
  @variable = Qa::LinkedData::Config::Helper.fetch_required(variable_map, :variable, nil)
  @required = Qa::LinkedData::Config::Helper.fetch_boolean(variable_map, :required, nil)
  @default = Qa::LinkedData::Config::Helper.fetch(variable_map, :default, '').to_s
  @encode = Qa::LinkedData::Config::Helper.fetch_boolean(variable_map, :encode, false)
  @property = Qa::LinkedData::Config::Helper.fetch(variable_map, :property, 'hydra:freetextQuery')
end