Class: SupplejackApi::Concept
- Inherits:
-
Object
- Object
- SupplejackApi::Concept
- Includes:
- ActiveModel::SerializerSupport, Support::Concept::Searchable, Support::Concept::Storable
- Defined in:
- app/models/supplejack_api/concept.rb
Constant Summary
Constants included from Support::Concept::Searchable
Support::Concept::Searchable::SUNSPOT_TYPE_NAMES
Class Method Summary collapse
Methods included from Support::Concept::Storable
Class Method Details
.build_context(fields) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/models/supplejack_api/concept.rb', line 15 def self.build_context(fields) context = {} namespaces = [] fields.each do |field| namespaces << ConceptSchema.model_fields[field].try(:namespace) end namespaces.compact.uniq.each do |namespace| context[namespace] = ConceptSchema.namespaces[namespace].url namespaced_fields = ConceptSchema.fields.select { |_key, field| field.namespace == namespace } namespaced_fields.each do |name, field| if fields.include?(name) && name != field.namespace context[name] = "#{field.namespace}:#{field.namespace_field}" end end end # Manually build context for concept_id context[:dcterms] = ConceptSchema.namespaces[:dcterms].url context[:concept_id] = {} context[:concept_id]['@id'] = 'dcterms:identifier' fields.each do |field| context[field] = {} namespace = ConceptSchema.model_fields[field].try(:namespace) context[field]['@id'] = "#{namespace}:#{field}" end context end |