Class: Qa::LinkedData::Config::ContextPropertyMap
- Inherits:
-
Object
- Object
- Qa::LinkedData::Config::ContextPropertyMap
- Defined in:
- app/models/qa/linked_data/config/context_property_map.rb
Constant Summary collapse
- VALUE_ON_ERROR =
[].freeze
Instance Attribute Summary collapse
-
#group_id ⇒ Object
readonly
id that identifies which group the property should be in.
-
#label ⇒ Object
readonly
id that identifies which group the property should be in.
Instance Method Summary collapse
-
#drillable? ⇒ Boolean
Can this property be used as a new query.
-
#expand_uri? ⇒ Boolean
Should this URI value be expanded to include its label?.
-
#expanded_values(graph, subject_uri) ⇒ Array<Hash>
Values of this property for a specfic subject URI with URI values expanded to include id and label.
- #group? ⇒ Boolean
-
#initialize(property_map = {}, prefixes = {}) ⇒ ContextPropertyMap
constructor
A new instance of ContextPropertyMap.
-
#optional? ⇒ Boolean
Should this property always be included in the extended context or is it optional (i.e. only shown if it has a value).
-
#selectable? ⇒ Boolean
Can this property be the selected value?.
-
#values(graph, subject_uri) ⇒ Array<String>
Values of this property for a specfic subject URI.
Constructor Details
#initialize(property_map = {}, prefixes = {}) ⇒ ContextPropertyMap
Returns a new instance of ContextPropertyMap.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/models/qa/linked_data/config/context_property_map.rb', line 33 def initialize(property_map = {}, prefixes = {}) @property_map = property_map @group_id = Qa::LinkedData::Config::Helper.fetch_symbol(property_map, :group_id, nil) @label = extract_label @ldpath = Qa::LinkedData::Config::Helper.fetch_required(property_map, :ldpath, false) @selectable = Qa::LinkedData::Config::Helper.fetch_boolean(property_map, :selectable, false) @drillable = Qa::LinkedData::Config::Helper.fetch_boolean(property_map, :drillable, false) @optional = Qa::LinkedData::Config::Helper.fetch_boolean(property_map, :optional, Qa.config.property_map_default_for_optional) @expansion_label_ldpath = Qa::LinkedData::Config::Helper.fetch(property_map, :expansion_label_ldpath, nil) @expansion_id_ldpath = Qa::LinkedData::Config::Helper.fetch(property_map, :expansion_id_ldpath, nil) @prefixes = prefixes end |
Instance Attribute Details
#group_id ⇒ Object (readonly)
id that identifies which group the property should be in
10 11 12 |
# File 'app/models/qa/linked_data/config/context_property_map.rb', line 10 def group_id @group_id end |
#label ⇒ Object (readonly)
id that identifies which group the property should be in
10 11 12 |
# File 'app/models/qa/linked_data/config/context_property_map.rb', line 10 def label @label end |
Instance Method Details
#drillable? ⇒ Boolean
Can this property be used as a new query
54 55 56 |
# File 'app/models/qa/linked_data/config/context_property_map.rb', line 54 def drillable? @drillable end |
#expand_uri? ⇒ Boolean
Should this URI value be expanded to include its label?
70 71 72 |
# File 'app/models/qa/linked_data/config/context_property_map.rb', line 70 def expansion_label_ldpath.present? end |
#expanded_values(graph, subject_uri) ⇒ Array<Hash>
Values of this property for a specfic subject URI with URI values expanded to include id and label.
88 89 90 91 92 93 94 95 96 |
# File 'app/models/qa/linked_data/config/context_property_map.rb', line 88 def (graph, subject_uri) values = values(graph, subject_uri) return values unless return values unless values.respond_to? :map! values.map! do |uri| { uri: uri, id: expansion_id(graph, uri), label: expansion_label(graph, uri) } end values end |
#group? ⇒ Boolean
64 65 66 |
# File 'app/models/qa/linked_data/config/context_property_map.rb', line 64 def group? group_id.present? end |
#optional? ⇒ Boolean
Should this property always be included in the extended context or is it optional (i.e. only shown if it has a value)
60 61 62 |
# File 'app/models/qa/linked_data/config/context_property_map.rb', line 60 def optional? @optional end |
#selectable? ⇒ Boolean
Can this property be the selected value?
48 49 50 |
# File 'app/models/qa/linked_data/config/context_property_map.rb', line 48 def selectable? @selectable end |
#values(graph, subject_uri) ⇒ Array<String>
Values of this property for a specfic subject URI
76 77 78 |
# File 'app/models/qa/linked_data/config/context_property_map.rb', line 76 def values(graph, subject_uri) Qa::LinkedData::LdpathService.ldpath_evaluate(program: basic_program, graph: graph, subject_uri: subject_uri) end |