Sha256: 6010e59517069b0adeeb3670d3cab4aba45340e7e38cab461aab26b25895c91c
Contents?: true
Size: 1.29 KB
Versions: 35
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module LinkedRails class Ontology class Base include ActiveModel::Model include LinkedRails::Model attr_accessor :iri def data data = [] iri.try(:each_statement) do |statement| next unless include_data_statement?(statement) statement.graph_name = ::RDF::Serializers.config.default_graph data << statement end data end def description @description ||= LinkedRails.translations( -> { LinkedRails.translate(self.class.translation_key, :description, iri) } ) end def image @image ||= RDF::URI("http://fontawesome.io/icon/#{icon}") if icon end def label @label ||= LinkedRails.translations( -> { LinkedRails.translate(self.class.translation_key, :label, iri) } ) end private def icon @icon ||= LinkedRails.translate(self.class.translation_key, :icon, iri) end def include_data_statement?(statement) return false if statement.subject.node? || statement.object.node? statement.predicate != Vocab.rdfs.label && statement.predicate != Vocab.rdfs.range && statement.predicate != Vocab.rdfs.domain end end end end
Version data entries
35 entries across 35 versions & 1 rubygems