UNC-Libraries/hy-c

View on GitHub
app/models/person.rb

Summary

Maintainability
A
0 mins
Test Coverage
C
77%
# frozen_string_literal: true
class Person < ActiveTriples::Resource

  property :index, predicate: ::RDF::Vocab::DC.identifier
  property :name, predicate: ::RDF::Vocab::MODS.name
  property :orcid, predicate: ::RDF::Vocab::Identifiers.orcid
  property :affiliation, predicate: ::RDF::Vocab::SCHEMA.affiliation
  property :other_affiliation, predicate: ::RDF::Vocab::EBUCore.hasAffiliation

  def initialize(uri = RDF::Node.new, parent = nil)
    if uri.try(:node?)
      uri = RDF::URI("#nested_person#{uri.to_s.gsub('_:', '')}")
    elsif uri.start_with?('#')
      uri = RDF::URI(uri)
    end
    super
  end

  def final_parent
    parent
  end

  def new_record?
    id.start_with?('#')
  end

  def _destroy
    false
  end
end